Click here to Skip to main content
15,886,833 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I have a code which generates Excel file in c# using closedXML.
C#
var workbook = new XLWorkbook();
var worksheet_1 = workbook.Worksheets.Add("Summary Report");
CreateLayout(worksheet_1, dt_Clone, dtS, strHeaderList, strReportHeader, additionalReportHeader);
FillData(ds, worksheet_1, dt_Clone);
worksheet_ProjectionSummary.PageSetup.PageOrientation = XLPageOrientation.Landscape;
string folder_path = Server.MapPath("~\\Reports\\");
string fileName = "SummaryReport_" + Session["Id"].ToString() + ".xlsx";
string fName = folder_path + fileName;

string[] fileEntries = Directory.GetFiles(folder_path);
foreach (string FName in fileEntries)
{
    if (FName.Contains("SummaryReport"))
    {
        System.IO.File.Delete(FName);
    }
}

workbook.SaveAs(fName);

This code works fine with office 2010 and windows 7.
However when I try to generate the same report using windows 8 and office 2013, I get a pop up saying file is corrupted.
When I save the file and re open in windows 8, it is working as expected.
Help me out here. How would i do open the file in windows 8 with out saving it?
Thanks in advance.
Posted
Updated 30-Mar-15 21:33pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900