Free Support Forum - aspose.com

Cannot open pivotTable source file!


Hi Team

I tried to save a workbook with pivot table using the following code

MemoryStream stream = new MemoryStream();

obj.ExcelWorkBook.Save(stream, FileFormatType.Default);

HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";

HttpContext.Current.Response.BinaryWrite(stream.ToArray());


file download dialog box will contain OPEN and SAVE buttons.
If I click the save button, it will save the file. If I click the open button, it displays that “cannot open pivotTable source file…”.
How to fix this issue?

Thanks

Samy T

Hi,

I think you may add a line to your code e.g

MemoryStream stream = new MemoryStream();

obj.ExcelWorkBook.Save(stream, FileFormatType.Default);

HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";

HttpContext.Current.Response.AddHeader( "content-disposition","inline; filename=MyoutBook.xls")

HttpContext.Current.Response.BinaryWrite(stream.ToArray());


And check the document for your reference:
https://docs.aspose.com/display/cellsnet/Pivot+Tables

Thank you.

Hi,

Thanks for the information but unfortunatley it made no difference and gave the following code

For your reference:

public static void ShowExcel(Workbook workbook, string fileName, bool inBrowser)

{

HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";

//HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + fileName + ".xls");

HttpContext.Current.Response.AddHeader("content-disposition", "inline; filename=" + fileName + ".xls");

if (inBrowser)

{

workbook.Save(fileName + ".xls", SaveType.OpenInBrowser, FileFormatType.Excel2003, HttpContext.Current.Response);

}

else

{

workbook.Save(fileName + ".xls", SaveType.OpenInExcel, FileFormatType.Default, HttpContext.Current.Response);

}

}

Thanks

SamyT

Hi,

Please save your file to disk or use only SaveType.OpenInExcel option if it works fine for your requirements. We will look into your issue further why you are not able to use SaveType.OpenInBrowser option fine there.

By the way, could you give us your environment details, OS, .NET framework, IIS Settings, and Browser type etc.

Thank you.