1.读EXCEL

	FileStream fs = new FileStream("C:\xx.xlsx", FileMode.Open, FileAccess.Read);
IWorkbook workbook = new XSSFWorkbook(fs);
fs.Dispose();

ISheet sheet = workbook.GetSheetAt(0);
int rowCount = sheet.LastRowNum;
for(int i = 0; i <= rowCount; i++)
{
IRow row = sheet.GetRow(i);
if (row == null) continue;
string sect1 = Convert.ToString(row.GetCell(0));
string sect2 = Convert.ToString(row.GetCell(1));
string sect3 = Convert.ToString(row.GetCell(2));
}


2.写EXCEL

	XSSFWorkbook wb = new XSSFWorkbook();
ISheet sheet = wb.CreateSheet();

for(int i = 0; i < xmlContet.Count(); i++)
{
IRow irow = sheet.CreateRow(i);
ICell icell = irow.CreateCell(0);
icell.SetCellValue(xmlContet[i]);
}

using (FileStream fs = File.OpenWrite(xmlFile + ".xlsx"))
{
wb.Write(fs);
wb.Close();
fs.Close();
}

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部