Free Support Forum - aspose.com

Export Workbook client side with GridWeb

Hi,

I just want to know if the Gridweb control handle the export on client side. I have made some research however I just found how to save the workbook on server side.

What I want to do is in fact like a “Save as” command which prompt a dialog to select the path and then export the workbook displayed with the GridWeb Control.

Thank you,
Romain.

Hi,


Well, I think you may save Excel file and then response the file to the client browser via Response steams, the client can specify the path and save as the file (in the default Download file dialog that the browser (e.g IE) displays) in his browser on his system.

See the sample code for reference:
protected void GridWeb1_SaveCommand(object sender, System.EventArgs e)
{
// Generates a temporary file name.
string filename = System.IO.Path.GetTempPath() + Session.SessionID + “.xls”;
  <span style="color: rgb(0, 128, 0);">// Saves to the file.</span>
  <span style="color: rgb(0, 0, 255);">this</span>.GridWeb1.WebWorksheets.SaveToExcelFile(filename);

  <span style="color: rgb(0, 128, 0);">// Sents the file to browser.</span>
  Response.ContentType = "<span style="color: rgb(139, 0, 0);">application/vnd.ms-excel</span>";

  <span style="color: rgb(0, 128, 0);">//Adds header.</span>
  Response.AddHeader("<span style="color: rgb(139, 0, 0);">content-disposition</span>", "<span style="color: rgb(139, 0, 0);">attachment; filename=book1.xls</span>");

  <span style="color: rgb(0, 128, 0);">// Writes file content to the response stream.</span>
  Response.WriteFile(filename);

  <span style="color: rgb(0, 128, 0);">// OK.</span>
  Response.End();
}</pre></div>

Hi,

Thank you this code works perfectly !

However when I save a Workbook using the xlsm extention, then I can not open it with Excel. It displays an Error of incorrect file format.

Does the GridWeb handle xlsm extention workbook saving ?

Thank you,
Romain.

Hi,

In the latest version for GridWeb, we included support for some more file formats to read/write, could you try our latest version Aspose.Cells.GridWeb, you may get it from the following link:

Let us know if it works fine. If you still find the issue, we will log a ticket into our database and look into it soon.

Thank you.

Hi,

That is already the version I use in my project and on which I have the issue.

So I wait for an update from you asap,
Thanks,
Romain.


Hi,


I tested loading a sample XLSM file into GridWeb with version v2.7.15.2000 and it works fine. GridWeb loads the file fine, here is my sample code that I am using:

// Clears datasheets first.
GridWeb1.WebWorksheets.Clear();
// Imports from a excel file.
GridWeb1.WebWorksheets.ImportExcelFile(“e:\test2\SampleBook1.xlsm”);

Please make sure that your using latest version i.e. v2.7.15.2000.

If you still find the issue, kindly create a simple project (runnable) with your template XLSM file, zip the project and attach it here, we will check it soon.

Thank you.

Hi,

I told about the save method:

string filename = System.IO.Path.GetTempPath() + Session.SessionID + “.xlsm”;
GridWeb1.WebWorksheets.SaveToExcelFile(filename);


GridWeb has always load a .xslm workbook fine so please try to save a xlsm workbook in your code.

Thank you.

Update : I have attached you a sample project which shows the issue, you just have to click on “Export” button and then try to open the exported file with MS Excel.

Hi,



Could you please try to specify the FileFormatType.XLSM using the SaveToExcelFile() overloads. I tested loading and saving the XLSM file with v2.7.15.2000, it works fine and the output XLSM file opens fine into MS Excel.
e.g
GridWeb1.WebWorksheets.SaveToExcelFile(“e:\test2\outputFile.xlsm” ,FileFormatType.XLSM);

Thank you.

Hi,

Now it works when I specify the FileFormatType.XLSM.

Thank you for your advice,
Romain.

Hi,


Good to know that your issue is resolved now.

Feel free to contact us any time if you have further query or have some other issue, we will be happy to assist you.

Thank you.