Size of excel


#1

When using the Excel.Save Method (String, FileFormatType, SaveType, HttpResponse) is there a way to find out the size of the excel before sending to the client?

Thanks,

Russ


#2

We don't provide the size property before saving because we are continously add new features to Aspose.Cells. It's hard to track the size.

You can try this workaround:

1. Save the file to a stream then get the size

MemoryStream stream = new MemoryStream();

excel.Save(stream, FileFormatType.Default);

int size = stream.Length;

2. Send the file to client with the following code:

byte[] data = stream.ToArray();

this.Response.ContentType = "application/xls";
Response.AddHeader( "content-disposition","inline; filename=book1.xls"); // OpenInBrowser

//Response.AddHeader( "content-disposition","attachment; filename=book1.xls"); // OpenInExcel
Response.BinaryWrite(data);
Response.End();


#3

Thanks for workaround!

Russ