tags:

views:

197

answers:

1

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?

+1  A: 

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

Windwaker