本文整理汇总了C#中Sheet.GetRow方法的典型用法代码示例。如果您正苦于以下问题:C# Sheet.GetRow方法的具体用法?C# Sheet.GetRow怎么用?C# Sheet.GetRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sheet
的用法示例。
在下文中一共展示了Sheet.GetRow方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRow
public static Row GetRow(Sheet sheet, int? row)
{
if (sheet != null)
{
if (row.HasValue)
{
var existingRow = sheet.GetRow(row.Value);
if (existingRow != null)
{
return existingRow;
}
return sheet.CreateRow(row.Value);
}
return sheet.CreateRow(sheet.LastRowNum + 1);
}
return null;
}
示例2: GetRow
public Row GetRow(Sheet sheet, int rowindex)
{
return sheet.GetRow(rowindex);
}
示例3: switch
private static string 得到流中列值(CellType cellType,Sheet sheet,int rowIndex,int cellIndex)
{
string value = string.Empty;
Cell cell=sheet.GetRow(rowIndex).GetCell(cellIndex);
switch (cell.CellType)
{
case CellType.STRING:
case CellType.BLANK:
{
value = cell.StringCellValue;
break;
}
case CellType.BOOLEAN:
{
value = cell.BooleanCellValue.ToString();
break;
}
case CellType.NUMERIC:
{
value = cell.NumericCellValue.ToString();
break;
}
}
return value;
}
示例4: GetHead
/// <summary>
/// 加載表頭
/// </summary>
private Sheet GetHead(Sheet tmpSheet, int startRowHeader, int col, string yearMonth)
{
DateTime date = Convert.ToDateTime(yearMonth + "/01");
DateTime weekDate = Convert.ToDateTime(yearMonth + "/01");
int days = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(date.Year, date.Month);
Row headRow = tmpSheet.CreateRow(0);
for (int d = 1; d <= days; d++)
{
tmpSheet.GetRow(startRowHeader).CreateCell(col + d - 1).SetCellValue(d.ToString());
weekDate = Convert.ToDateTime(yearMonth + "/" + d.ToString());
DateTime str = Convert.ToDateTime(yearMonth + "/" + d.ToString());
// string weekDay = GetWeekstr(yearMonth + "/" + d.ToString());
string weekDay = GetWeek(str);
tmpSheet.GetRow(startRowHeader + 1).CreateCell(col + d - 1).SetCellValue(weekDay.ToString());
}
return tmpSheet;
}
示例5: SetComment
/// <summary>
/// 插入批注
/// </summary>
/// <param name="count"></param>
/// <param name="sheet"></param>
/// <param name="patriarch"></param>
private void SetComment(int count, Sheet sheet, Drawing patriarch)
{
StringBuilder sb = new StringBuilder();
sb.Append("这个Excel文件完全由代码生成,并非是在原有模板上填充数据.\r\n");
sb.Append("文件创建于" + DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss\r\n"));
sb.Append("\r\n给力啊,IT!!!");
sb.Append("\r\nhttp://www.woshinidezhu.com/");
sb.Append("\r\nhttp://woshinidezhu.cnblogs.com/");
/*****************************************************************
* HSSFClientAnchor:批注位置,8个参数分别表示
* {1}距离左边单元格的距离,1024为100%,即从右方一个单元格开始
* {2}距离上方单元格的距离,255为100%,即从下方一个单元格开始
* {3}右边单元格超出的距离,1024为100%,即充满到右方一个单
* {4}下方单元格超出的距离,255为100%,即充满到下方一个单元格
* {5}起始列
* {6}起始行
* {7}结束列
* {8}结束行
*****************************************************************/
Comment comment = patriarch.CreateCellComment(new HSSFClientAnchor(600, 100, 500, 200, 1, 3 + count, 7, 3 + 7 + count));
comment.String = new HSSFRichTextString(sb.ToString());
comment.Visible = true;//默认打开即可见
sheet.GetRow(2 + count).CreateCell(0).CellComment = comment;
}
示例6: CreateCell
/// <summary>
/// 創建單元格
/// </summary>
/// <param name="cellSheet"></param>
/// <param name="row"></param>
private Row CreateCell(Sheet ySheet, Sheet cloneSheet, int row, int stRow)
{
Row cellRow = cloneSheet.CreateRow(row);
cellRow.Height = ySheet.GetRow(stRow).Height;
for (int c = 0; c <= 10; c++)
cellRow.CreateCell(c).CellStyle = ySheet.GetRow(stRow).GetCell(c).CellStyle;
return cellRow;
}