更改电子表格会导致格式化丢失

时间:2015-03-23 20:34:43

标签: c# .net excel

我使用excellibrary库来处理excel。我的代码是

        Workbook book = Workbook.Load(book_name);
        Workbook book_new = Workbook.Load(file_name);

        Worksheet sheet = book.Worksheets[0];
        Worksheet sheet_new = book_new.Worksheets[0];

        for (int rowIndex = 7; rowIndex <= 2235; rowIndex++)
        {
            Console.WriteLine(sheet.Cells[rowIndex, ost_index] + " " + sheet_new.Cells[rowIndex, ost_index]);

            sheet.Cells[rowIndex, ost_index] = sheet_new.Cells[rowIndex, ost_index];
            sheet.Cells[rowIndex, price_index] = sheet_new.Cells[rowIndex, price_index];
        }

        book.Save(book_name);

在此代码中,我将两个cols从一个文件复制到另一个文件。而且有一个问题。这个excel文件有很多样式,如超链接等。当我使用程序后打开文件时,我看到一个文本无法读取文件的窗口。点击“ok ... ok ... ok ...”后,我看到没有格式化的文件(没有颜色,没有样式等等)。我该怎么修呢? 附:对不起我的英文。

1 个答案:

答案 0 :(得分:0)

这似乎是库中已知的bug,并且由于自报告以来库尚未更新,此时您最好的选择是切换到另一个库。