Workbook 对象 (Excel)
Workbook book = new Workbook();
//1.打开指定模板文件
book.Open(“Z:XX.xlsx”);////读Excel写法
book.FromJson(System.IO.File.ReadAllText(json_path)); //读Json写法
//2.保存Excel&Json
System.IO.File.WriteAllText("Z:\\XXX.json", book.ToJson());
book.Save("Z:\\XXX.xlsx");
3.读取Excel&Json
System.IO.File.ReadAllText(System.IO.Path.Combine(templatePath));
4.文件备份
System.IO.File.Copy("备份文件路径", “新路径”);
5.Workbook可以理解为整个Excel对象.
6.循环Workbook里边Worksheets.
for (int i = 0; i < workbook.Worksheets.Count; i++)
{
//1.获取sheet页操作
var sheet = workbook.Worksheets[i];
//2.循环遍历行
for (int c = 0; c < sheet.GetUsedRange().Rows.Count; c++)
{
//3.得到列
var cells = range.Rows[c].Cells;
for (int b = 1; b <= cells.Count; b++)
{
//行列单元格的值
cells[b].Value
}
}
}