本文整理汇总了C#中ISheet.GetRow方法的典型用法代码示例。如果您正苦于以下问题:C# ISheet.GetRow方法的具体用法?C# ISheet.GetRow怎么用?C# ISheet.GetRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISheet
的用法示例。
在下文中一共展示了ISheet.GetRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadSheet
//シートの読み込み
static StringGrid ReadSheet(ISheet sheet, string path)
{
int lastRowNum = sheet.LastRowNum;
StringGrid grid = new StringGrid(path + ":" + sheet.SheetName, CsvType.Tsv);
for (int rowIndex = sheet.FirstRowNum; rowIndex <= lastRowNum; ++rowIndex)
{
IRow row = sheet.GetRow(rowIndex);
List<string> stringList = new List<string>();
if (row != null)
{
foreach (var cell in row.Cells)
{
for (int i = stringList.Count; i < cell.ColumnIndex; ++i)
{
stringList.Add("");
}
stringList.Add(cell.ToString());
}
}
grid.AddRow(stringList);
}
grid.ParseHeader();
return grid;
}
示例2: SheetImport
private static void SheetImport(Tk5ListMetaData metaInfos, DataTable dataTable, ISheet sheet,
ResultHolder resultHolder)
{
if (sheet != null)
{
// resultHolder.SheetName = metaInfos.Table.TableDesc;
Dictionary<string, Tk5FieldInfoEx> dicOfInfo = new Dictionary<string, Tk5FieldInfoEx>();
foreach (Tk5FieldInfoEx info in metaInfos.Table.TableList)
{
dicOfInfo.Add(info.DisplayName, info);
}
IRow headerRow = sheet.GetRow(0);
for (int i = (sheet.FirstRowNum + 1); i <= sheet.LastRowNum; i++)
{
IRow row = sheet.GetRow(i);
DataRow dataRow = dataTable.NewRow();
for (int j = row.FirstCellNum; j < row.LastCellNum; j++)
{
string columnName = headerRow.GetCell(j).ToString();
string strValue = row.GetCell(j).ToString();
ImportResult imResult = TablePadding(dataRow, columnName, dicOfInfo, strValue, i);
if (imResult != null)
{
resultHolder.Add(imResult);
}
}
dataTable.Rows.Add(dataRow);
}
}
}
示例3: GetChambrePMZ
private ChambrePA GetChambrePMZ(ISheet sheet)
{
var geofibrePMZ = sheet.GetRow(10).GetCell(11).ToString();
var identifiantPMZ = sheet.GetRow(10).GetCell(13).ToString();
return new ChambrePA(geofibrePMZ, identifiantPMZ);
}
示例4: AddBorder
/// <summary>
/// 加边框
/// </summary>
/// <param Name="rowindex">1开始</param>
/// <param Name="cellIndex">1开始</param>
public void AddBorder( ISheet sheet, HSSFWorkbook workbook)
{
ICellStyle styel = workbook.CreateCellStyle();
styel.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; // ------------------
IFont font1 = workbook.CreateFont();
font1.FontHeightInPoints = 11;
font1.Boldweight = 600;
font1.FontName = "宋体";
styel.SetFont(font1);
for (int rowindex=1;rowindex<sheet.LastRowNum+1;rowindex++)
{
for (int cellIndex =0; cellIndex < dcs.Count;cellIndex++ )
{
sheet.GetRow(rowindex).RowStyle = styel;
ICell cell = sheet.GetRow(rowindex ).GetCell(cellIndex );
HSSFCellStyle Style = workbook.CreateCellStyle() as HSSFCellStyle;
Style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
Style.VerticalAlignment = VerticalAlignment.Center;
Style.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
Style.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
Style.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
Style.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
Style.DataFormat = 0;
Style.SetFont(font1);
cell.CellStyle = Style;
}
}
}
示例5: GetChambrePA
private ChambrePointAboutement GetChambrePA(ISheet sheet)
{
var geofibrePA = sheet.GetRow(11).GetCell(11).ToString();
var chambrePA = sheet.GetRow(13).GetCell(10).ToString();
return new ChambrePointAboutement(geofibrePA, chambrePA);
}
示例6: SameCell
/**
* Highlight cells based on their values
*/
static void SameCell(ISheet sheet)
{
sheet.CreateRow(0).CreateCell(0).SetCellValue(84);
sheet.CreateRow(1).CreateCell(0).SetCellValue(74);
sheet.CreateRow(2).CreateCell(0).SetCellValue(50);
sheet.CreateRow(3).CreateCell(0).SetCellValue(51);
sheet.CreateRow(4).CreateCell(0).SetCellValue(49);
sheet.CreateRow(5).CreateCell(0).SetCellValue(41);
ISheetConditionalFormatting sheetCF = sheet.SheetConditionalFormatting;
// Condition 1: Cell Value Is greater than 70 (Blue Fill)
IConditionalFormattingRule rule1 = sheetCF.CreateConditionalFormattingRule(ComparisonOperator.GreaterThan, "70");
IPatternFormatting fill1 = rule1.CreatePatternFormatting();
fill1.FillBackgroundColor = (IndexedColors.Blue.Index);
fill1.FillPattern = (short)FillPattern.SolidForeground;
// Condition 2: Cell Value Is less than 50 (Green Fill)
IConditionalFormattingRule rule2 = sheetCF.CreateConditionalFormattingRule(ComparisonOperator.LessThan, "50");
IPatternFormatting fill2 = rule2.CreatePatternFormatting();
fill2.FillBackgroundColor = (IndexedColors.Green.Index);
fill2.FillPattern= (short)FillPattern.SolidForeground;
CellRangeAddress[] regions = {
CellRangeAddress.ValueOf("A1:A6")
};
sheetCF.AddConditionalFormatting(regions, rule1, rule2);
sheet.GetRow(0).CreateCell(2).SetCellValue("<== Condition 1: Cell Value is greater than 70 (Blue Fill)");
sheet.GetRow(4).CreateCell(2).SetCellValue("<== Condition 2: Cell Value is less than 50 (Green Fill)");
}
示例7: ReadExcel
private IEnumerable<PositionnementEtudeSheet> ReadExcel(ISheet sheet)
{
var rowNumber = 4;
while (sheet.GetRow(rowNumber).GetCell(0) != null && sheet.GetRow(rowNumber).GetCell(0).ToString() != string.Empty)
{
var rows = GetRows(sheet, rowNumber).ToList();
rowNumber += rows.Count;
yield return new PositionnementEtudeSheet(rows);
}
}
示例8: GetCellNumic
public static double GetCellNumic(ISheet sheet, char x, int y)
{
double _r = double.MinValue;
ICell cell = sheet.GetRow(y - 1).GetCell(GetCellIntFromChar(x) - 1);
if (cell != null)
switch (cell.CellType)
{
case CellType.String:
{
_r = double.Parse(cell.StringCellValue.Trim());
}
break;
case CellType.Numeric:
{
_r = cell.NumericCellValue;
}
break;
default:
{
}
break;
}
return _r;
}
示例9: SheetImport
private static void SheetImport(Tk5ListMetaData metaInfos, DataTable dataTable, ISheet sheet,
ImportError importError)
{
if (sheet != null)
{
Dictionary<string, Tk5FieldInfoEx> dicOfInfo = new Dictionary<string, Tk5FieldInfoEx>();
foreach (Tk5FieldInfoEx info in metaInfos.Table.TableList)
{
dicOfInfo.Add(info.DisplayName, info);
}
IRow headerRow = sheet.GetRow(0);
IRow row = null;
string columnName = string.Empty;
string strValue = string.Empty;
ICell cell = null;
for (int i = (sheet.FirstRowNum + 1); i <= sheet.LastRowNum; i++)
{
row = sheet.GetRow(i);
DataRow dataRow = dataTable.NewRow();
bool rowError = false;
for (int j = headerRow.FirstCellNum; j < headerRow.LastCellNum; j++)
{
columnName = headerRow.GetCell(j).ToString();
cell = row.GetCell(j);
strValue = ((cell == null) ? null : cell.ToString());
var imResult = TablePadding(dataRow, columnName, dicOfInfo, strValue, i);
if (imResult != null)
{
importError.Add(imResult);
rowError = true;
}
}
if (!rowError)
{
dataRow["OriginalRowNum"] = i;
dataTable.Rows.Add(dataRow);
}
}
}
}
示例10: LoadProjects
private void LoadProjects(ISheet sheet, int rowStartIndex, List<Project> projects)
{
int maxColCount = 40;
int rowheight = 20;
for (int col = 1; col < maxColCount; col = col + 2)
{
ICell repCell = sheet.GetRow(rowStartIndex + 1).GetCell(col);
ICell nameCell = sheet.GetRow(rowStartIndex + 2).GetCell(col);
ICell idCell = sheet.GetRow(rowStartIndex).GetCell(col);
if (GetCellValue(repCell) == null || GetCellValue(nameCell) == null || GetCellValue(idCell) == null)
{
continue;
}
Project project = new Project();
project.Assignment = GetCellValue(idCell);
project.Name = GetCellValue(nameCell);
project.Rep = Regex.Replace(GetCellValue(repCell), @"\s+", "").ToLower();
for (int row = rowStartIndex + 3; row < rowheight + rowStartIndex; row++)
{
IRow rowObj = sheet.GetRow(row);
if (rowObj == null)
{
continue;
}
ICell cell = rowObj.GetCell(col);
string value = GetCellValue(cell);
if (value != null)
{
project.Members.Add(Regex.Replace(value, @"\s+", "").ToLower());
}
}
projects.Add(project);
}
}
示例11: AutoSizeColumns
/// <summary>
/// 自动设置Excel列宽
/// </summary>
/// <param name="sheet">Excel表</param>
private static void AutoSizeColumns(ISheet sheet)
{
if (sheet.PhysicalNumberOfRows > 0)
{
IRow headerRow = sheet.GetRow(0);
for (int i = 0, l = headerRow.LastCellNum; i < l; i++)
{
sheet.AutoSizeColumn(i);
}
}
}
示例12: CheckSchedule
public bool CheckSchedule(ISheet sheet, string anchorKey)
{
for (int i = 0; i <= sheet.LastRowNum; i++)
{
var cell = sheet.GetRow(i).Cells.Where(x => x.CellType == CellType.String && x.StringCellValue.ToLower().Contains(anchorKey.ToLower())).LastOrDefault();
if (cell != null)
{
return true;
}
}
return false;
}
示例13: CreateWorksheet
Worksheet CreateWorksheet(ISheet sheet)
{
var rows = new List<IRow>();
int maxColumns = 0;
for (int i = 0; i < sheet.PhysicalNumberOfRows; i++)
{
IRow row = sheet.GetRow(i);
maxColumns = Math.Max(maxColumns, row.LastCellNum);
rows.Add(row);
}
return new Worksheet(sheet.SheetName, maxColumns, rows.Select(row => CreateRow(row, maxColumns)));
}
示例14: AddContents
private static void AddContents(ISheet sheet, ICollection<List<string>> rowsAndCells)
{
var lastRow = sheet.LastRowNum;
for (int i = 1; i <= lastRow; i++)
{
var row = new List<string>();
row.AddRange(
sheet.GetRow(i)
.Cells.Select(
x => x.CellType == CellType.Numeric ? x.NumericCellValue.ToString(CultureInfo.InvariantCulture) : x.StringCellValue));
rowsAndCells.Add(row);
}
}
示例15: ParseGoodSale
private IEnumerable<SaleParsed> ParseGoodSale(ISheet sheet, GoodType good, DateTime dateTime, int customerColumn, int startRow)
{
var sales = new List<SaleParsed>();
for (int r = startRow; ; r++)
{
var row = sheet.GetRow(r);
if (row == null)
break;
var customerCell = row.GetCell(customerColumn);
if (customerCell == null || string.IsNullOrWhiteSpace(customerCell.StringCellValue))
break;
var customer = customerCell.StringCellValue.Trim();
int qty = 0, ret = 0;
var qtyCell = sheet.GetRow(r).GetCell(good.ColumnInDocument - 1);
if (qtyCell != null && qtyCell.CellType == CellType.Numeric
&& qtyCell.NumericCellValue > 0)
{
qty = (int)qtyCell.NumericCellValue;
}
if (good.HasReturn)
{
var retCell = sheet.GetRow(r).GetCell(good.ReturnColumn.Value - 1);
if (retCell != null && retCell.CellType == CellType.Numeric
&& retCell.NumericCellValue > 0)
{
ret = (int)retCell.NumericCellValue;
}
}
if (qty > 0 && qty > ret)
{
var sale = new SaleParsed();
sale.GoodType = good;
sale.DateTime = dateTime;
sale.Customer = customer;
sale.Producer = producer;
sale.Quantity = qty;
sale.Return = ret;
sales.Add(sale);
}
}
return sales;
}