1

尝试使用 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 文件的所有内容复制到另一个文件的最佳方法是什么?

4

1 回答 1

1

FileStream file = new FileStream(inputFilePath, FileMode.Create, FileAccess.Write);
doc.Save(文件);
文件。关闭();

于 2010-08-04T14:23:57.183 回答