Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 文件包含损坏的数据EPPlus_Excel_Xlsx_Epplus - Fatal编程技术网

Excel 文件包含损坏的数据EPPlus

Excel 文件包含损坏的数据EPPlus,excel,xlsx,epplus,Excel,Xlsx,Epplus,我正在尝试使用EPPlus从现有的excel工作表(xlsx)创建一个新的excel工作表(xlsx) 我现有的excel工作表包含4个工作表,我想更新新excel工作表中的一些单元格并保存在新位置 这是我的密码 public string RunSample22(DirectoryInfo outputDir) { FileInfo tempFile = new FileInfo(@"F:\bin\Debug\ReportTemplateFile.xlsx"); // Mak

我正在尝试使用EPPlus从现有的excel工作表(xlsx)创建一个新的excel工作表(xlsx)

我现有的excel工作表包含4个工作表,我想更新新excel工作表中的一些单元格并保存在新位置

这是我的密码

public string RunSample22(DirectoryInfo outputDir)
{
    FileInfo tempFile = new FileInfo(@"F:\bin\Debug\ReportTemplateFile.xlsx");

    // Making a new file 'Sample2.xlsx'
    FileInfo newFile = new FileInfo(@"E:\Test" + @"\Sample22.xlsx");

    if (newFile.Exists)
    {
        newFile.Delete();
        newFile = new FileInfo(outputDir.FullName + @"\Sample22.xls");
    }

    using (ExcelPackage package = new ExcelPackage(newFile, tempFile ))   // getting error in this line
    {
        // Openning first Worksheet of the template file i.e. 'Sample1.xlsx'
        ExcelWorksheet worksheet = package.Workbook.Worksheets[1];

        worksheet.Cells[1, 1].Value = "Test";

        // Save our new workbook
        package.Save();
    }
    return newFile.FullName;
}
并在我的捕捉块中低于错误

“文件包含损坏的数据。”


我遗漏了什么或有什么建议。

你能更具体一点吗?原始Excel文件是否包含EPPlus明确不支持的数据?我在EPPlus中也遇到了一些数据损坏的问题(至少在版本3.x中)。您正在使用哪个版本的EPPlus。。。也许你应该试试4.x(目前正在测试版)?