随手记录,我自己也搞不明白。直接拿去用了
public static string ReadXLSX(string filePath)
{
string sb="";
using (var file = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
var hssfworkbook = new XSSFWorkbook(file);
var sheet = hssfworkbook.GetSheetAt(0);
var rows = sheet.GetRowEnumerator();
while (rows.MoveNext())
{
var row = (XSSFRow)rows.Current;
for (var i = 0; i < row.LastCellNum; i++)
{
string cell = row.GetCell(i).ToString();
sb += "\r\n" + cell;
}
}
}
return sb;
}
标签:rows,读取,C#,Excel,file,var,sb,string,row From: https://blog.51cto.com/u_16371710/9238052