本文整理汇总了C#中ISheet.CreateRow方法的典型用法代码示例。如果您正苦于以下问题:C# ISheet.CreateRow方法的具体用法?C# ISheet.CreateRow怎么用?C# ISheet.CreateRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISheet
的用法示例。
在下文中一共展示了ISheet.CreateRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddDateRangetoExcelSheet
public void AddDateRangetoExcelSheet(HSSFWorkbook workbook, ISheet sheet)
{
//Create a Title row
var titleFont = workbook.CreateFont();
titleFont.Boldweight = (short)NPOI.SS.UserModel.FontBoldWeight.Bold;
titleFont.FontHeightInPoints = 11;
titleFont.Underline = NPOI.SS.UserModel.FontUnderlineType.Single;
var titleStyle = workbook.CreateCellStyle();
titleStyle.SetFont(titleFont);
var row = sheet.CreateRow(rowCount++);
var cell = row.CreateCell(0);
cell.CellStyle = titleStyle;
cell.SetCellValue("Date Range");
row = sheet.CreateRow(rowCount++);
cell = row.CreateCell(0);
var value = string.Format("Start Date: {0}", StartDate.ToString("MM-dd-yyyy"));
cell.SetCellValue(value);
row = sheet.CreateRow(rowCount++);
cell = row.CreateCell(0);
value = string.Format("End Date: {0}", EndDate.ToString("MM-dd-yyyy"));
cell.SetCellValue(value);
}
示例2: OutputDateRow
private static void OutputDateRow(ISheet sheet, IEnumerable<string> distinctDates, int rowIndex)
{
var colSpan = 3;
var startCol = 1;
var dateRow = sheet.CreateRow(rowIndex);
var headerRow = sheet.CreateRow(rowIndex + 1);
dateRow.CreateCell(0).SetCellValue("");
headerRow.CreateCell(0).SetCellValue("");
for (var i = 0; i < distinctDates.Count(); i++)
{
var cell = dateRow.CreateCell(startCol);
cell.SetCellValue(distinctDates.ElementAt(i));
sheet.AddMergedRegion(new CellRangeAddress(rowIndex, rowIndex, startCol, colSpan * (i + 1)));
headerRow.CreateCell(startCol).SetCellValue(ValueHeader);
headerRow.CreateCell(startCol + 1).SetCellValue(PrefixHeader);
headerRow.CreateCell(startCol + 2).SetCellValue(DlHeader);
startCol = startCol + colSpan;
}
}
示例3: AddListToExcelSheet
public void AddListToExcelSheet(HSSFWorkbook workbook, ISheet sheet, string Title, Dictionary<string, bool> list)
{
//Create a Title row
var titleFont = workbook.CreateFont();
titleFont.Boldweight = (short)NPOI.SS.UserModel.FontBoldWeight.Bold;
titleFont.FontHeightInPoints = 11;
titleFont.Underline = NPOI.SS.UserModel.FontUnderlineType.Single;
var titleStyle = workbook.CreateCellStyle();
titleStyle.SetFont(titleFont);
var row = sheet.CreateRow(rowCount++);
row = sheet.CreateRow(rowCount++);
var cell = row.CreateCell(0);
cell.CellStyle = titleStyle;
cell.SetCellValue(Title);
foreach (var org in list)
{
if (org.Value == true)
{
row = sheet.CreateRow(rowCount++);
cell = row.CreateCell(0);
cell.SetCellValue(org.Key);
}
}
}
示例4: CreateHeaderRow
static void CreateHeaderRow(ISheet _sheet)
{
IRow header = _sheet.CreateRow(1);
int cellIdx = 1;
// name
ICell nameCell = header.CreateCell(cellIdx++);
nameCell.SetCellValue("name");
// hp
ICell hpCell = header.CreateCell(cellIdx++);
hpCell.SetCellValue("hp");
// x
ICell posxCell = header.CreateCell(cellIdx++);
posxCell.SetCellValue("x");
// y
ICell posyCell = header.CreateCell(cellIdx++);
posyCell.SetCellValue("y");
// z
ICell poszCell = header.CreateCell(cellIdx++);
poszCell.SetCellValue("z");
}
示例5: WriteHeaderRow
static void WriteHeaderRow(IWorkbook wb, ISheet sheet)
{
sheet.SetColumnWidth(0, 6000);
sheet.SetColumnWidth(1, 6000);
sheet.SetColumnWidth(2, 3600);
sheet.SetColumnWidth(3, 3600);
sheet.SetColumnWidth(4, 2400);
sheet.SetColumnWidth(5, 2400);
sheet.SetColumnWidth(6, 2400);
sheet.SetColumnWidth(7, 2400);
sheet.SetColumnWidth(8, 2400);
IRow row = sheet.CreateRow(0);
ICellStyle style = wb.CreateCellStyle();
IFont font = wb.CreateFont();
font.Boldweight = (short)FontBoldWeight.BOLD;
style.SetFont(font);
WriteHeaderCell(row, 0, "Raw Long Bits A", style);
WriteHeaderCell(row, 1, "Raw Long Bits B", style);
WriteHeaderCell(row, 2, "Value A", style);
WriteHeaderCell(row, 3, "Value B", style);
WriteHeaderCell(row, 4, "Exp Cmp", style);
WriteHeaderCell(row, 5, "LT", style);
WriteHeaderCell(row, 6, "EQ", style);
WriteHeaderCell(row, 7, "GT", style);
WriteHeaderCell(row, 8, "Check", style);
}
示例6: Init
public bool Init()
{
if (!File.Exists(m_StrategyName))
{
m_StrategyWorkBook = new XSSFWorkbook();
m_StrategySheet = (ISheet)m_StrategyWorkBook.CreateSheet("Sheet1");
IRow Row = m_StrategySheet.CreateRow(0);
Row.CreateCell(0).SetCellValue("-500");
Row.CreateCell(1).SetCellValue("-450");
Row.CreateCell(2).SetCellValue("-400");
Row.CreateCell(3).SetCellValue("-350");
Row.CreateCell(4).SetCellValue("-300");
Row.CreateCell(5).SetCellValue("-250");
Row.CreateCell(6).SetCellValue("-200");
Row.CreateCell(7).SetCellValue("-150");
Row.CreateCell(8).SetCellValue("-100");
Row.CreateCell(9).SetCellValue("-50");
Row.CreateCell(10).SetCellValue("0");
Row.CreateCell(11).SetCellValue("50");
Row.CreateCell(12).SetCellValue("100");
Row.CreateCell(13).SetCellValue("150");
Row.CreateCell(14).SetCellValue("200");
Row.CreateCell(15).SetCellValue("250");
Row.CreateCell(16).SetCellValue("300");
Row.CreateCell(17).SetCellValue("350");
Row.CreateCell(18).SetCellValue("400");
Row.CreateCell(19).SetCellValue("450");
Row.CreateCell(20).SetCellValue("500");
return true;
}
return false;
}
示例7: AddToExcel
static void AddToExcel(ISheet _sheet, CharaData _data, int _rowIdx)
{
IRow row = _sheet.CreateRow(_rowIdx);
int cellIdx = 1;
// name
ICell nameCell = row.CreateCell(cellIdx++);
nameCell.SetCellValue(_data.m_name);
// hp
ICell hpCell = row.CreateCell(cellIdx++);
hpCell.SetCellValue(_data.m_hp);
// x
ICell posxCell = row.CreateCell(cellIdx++);
posxCell.SetCellValue(_data.m_position.x);
// y
ICell posyCell = row.CreateCell(cellIdx++);
posyCell.SetCellValue(_data.m_position.y);
// z
ICell poszCell = row.CreateCell(cellIdx++);
poszCell.SetCellValue(_data.m_position.z);
}
示例8: CreateDataRow
// convenient access to namespace
//private static ErrorEval EE = null;
private static void CreateDataRow(ISheet sheet, int rowIndex, params double[] vals)
{
IRow row = sheet.CreateRow(rowIndex);
for (int i = 0; i < vals.Length; i++)
{
row.CreateCell(i).SetCellValue(vals[i]);
}
}
示例9: CreateBody
// 创建 Excel 内容主体
private void CreateBody(ISheet sheet, IEnumerable<object[]> columnDatas)
{
var i = 1; // 第二行开始
foreach (var data in columnDatas)
{
var row = sheet.CreateRow(i++);
this.CreateRow(row, data);
}
}
示例10: CreateRows
public void CreateRows(int rowsCount, int cellsCount, ref ISheet sheet, IList<string> cellsValues = null)
{
if (sheet == null) return;
for (var i = 1; i <= rowsCount; i++)
{
var r = sheet.CreateRow(i);
CreateCells(cellsCount, ref r, cellsValues);
}
}
示例11: AddDataToReport
private void AddDataToReport(ISheet worksheet, DefaultExceptionScheduleReportData[] items, bool isDefault = true)
{
var rowIndex = worksheet.LastRowNum + 1;
var dateTitle = DateTime.MinValue;
foreach (var item in items)
{
IRow row;
if (isDefault)
{
row = worksheet.CreateRow(rowIndex++);
WriteCell(row, 0, c => c.SetCellValue(item.ScheduleDate.ToShortDateString()));
}
else
{
if (dateTitle != item.ScheduleDate)
{
dateTitle = item.ScheduleDate;
row = worksheet.CreateRow(rowIndex++);
WriteCell(row, 0, c => c.SetCellValue(dateTitle.ToShortDateString()), styles[StandardCellStyles.BoldStyle]);
}
row = worksheet.CreateRow(rowIndex++);
WriteCell(row, 0, c => c.SetCellValue((item as ServiceExceptionScheduleReportData).Service));
}
WriteCell(row, 1, c => c.SetCellValue(item.IsWorked ? "Да" : "Нет"));
if (item.IsWorked)
{
WriteCell(row, 2, c => c.SetCellValue(item.StartTime.ToString()));
WriteCell(row, 3, c => c.SetCellValue(item.FinishTime.ToString()));
WriteCell(row, 4, c => c.SetCellValue(item.ClientInterval.Minutes));
WriteCell(row, 5, c => c.SetCellValue(item.Intersection.Minutes));
WriteCell(row, 6, c => c.SetCellValue(item.MaxClientRequests));
}
};
}
示例12: CreateRowHeader
/// <summary>
/// sheet 抬头
/// </summary>
/// <param name="sheet">sheet 对象</param>
private void CreateRowHeader(ISheet sheet)
{
var row = sheet.CreateRow(0);
for (var i = 0; i < this._columnNames.Length; i++)
{
var cell = row.CreateCell(i);
this.WriteToCell(cell, typeof(string), this._columnNames[i]);
}
this.CreateRow(row, this._columnNames, false);
}
示例13: GenerateRow
static void GenerateRow(ISheet sheet1,int rowid,string firstName, string lastName, double salaryAmount, double taxRate)
{
IRow row = sheet1.CreateRow(rowid);
row.CreateCell(0).SetCellValue(firstName); //A2
row.CreateCell(1).SetCellValue(lastName); //B2
row.CreateCell(2).SetCellValue(salaryAmount); //C2
row.CreateCell(3).SetCellValue(taxRate); //D2
row.CreateCell(4).SetCellFormula(string.Format("C{0}*D{0}",rowid+1));
row.CreateCell(5).SetCellFormula(string.Format("C{0}-E{0}", rowid + 1));
}
示例14: CreateCellArray
static void CreateCellArray(ISheet sheet)
{
for (int i = 0; i < 300; i++)
{
IRow row=sheet.CreateRow(i);
for (int j = 0; j < 150; j++)
{
ICell cell = row.CreateCell(j);
cell.SetCellValue(i*j);
}
}
}
示例15: CreateHeader
private static void CreateHeader(ISheet workSheet, IEnumerable<Cell> cells)
{
var header = workSheet.CreateRow(0);
var currentCol = 0;
foreach (var cell in cells)
{
header.CreateCell(currentCol).SetCellValue(cell.Title);
currentCol++;
}
}