我正在使用EPPlus库在我的.net core web api中。在该方法中,我想验证上传的excel文件。我想找出整行是否为空。我有以下代码:
using (ExcelPackage package = new ExcelPackage(file.OpenReadStream()))
{
ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
int rowCount = worksheet.Dimension.End.Row;
int colCount = worksheet.Dimension.End.Column;
//loop through rows and columns
for (int row = 1; row <= rowCount; row++)
{
for (int col = 1; col <= ColCount; col++)
{
var rowValue = worksheet.Cells[row, col].Value;
//Want to find here if the entire row is empty
}
}
}
如果特定单元格为空,rowValue将告诉我。是否可能检查整行并在为空时继续下一行?