尝试使用 MyXls 编辑我的文件:
XlsDocument doc = new XlsDocument(InputFilePath);
Worksheet sheet = doc.Workbook.Worksheets[InputSheet.Substring(0, InputSheet.Length - 1)];
foreach (var row in sheet)
{
if (row.CellCount > 1)
{
Cell firstCell = row.GetCell(1);
firstCell.Font.Weight = FontWeight.Bold;
}
}
doc.Save();//Here is a nullreference Exception without any explanations
MyXLs 似乎无法写入我的文件;示例仅用于创建新文件。如果是这样,使用此库将一个 xls 文件的所有内容复制到另一个文件的最佳方法是什么?