开发者

MyXls lib doesn't edit existing file

Trying to edit my file with 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

It seems that MyXLs cannot write into my file; example is for creating new file only. If so, what is the best way to copy all the contents of one xls file into another with this lib?


FileStream file = new FileStream(inputFilePath, FileMode.Create, FileAccess.Write);
doc.Save(file);
file.Close();

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜