Free Support Forum - aspose.com

Just wandering

In evaluation of your product, why not dump datatable to a html table and then export to excel ?

Why do you need this feature?

It's very easy to import datatable into excel through Aspose.Cells using Cells.ImportDataTable method.

Laurence,

I am just playing advocate of the devil and trying to sum up why i would not buy your product.

I just want to export some statistical data (coming from Dataset/table) to excel and was wandering if it were possible to dump it to a html table and let excel open this.

In another application, i need to export an xml file (coming from a webservice) to an excel file.

I was just in search for the right solution and... (read: solid and fast development)

kind regards and thank you for the effort, Tom.

Hi Tom,

Aspose.Cells doesn't support to import/export html yet. However, if your data is coming from DataSet/DataTable, it's very easy to populate it into Excel without needing to dump it to an html table. Please check Cells.ImportDataTable method.

About the xml file, is it a spreadsheetML file? If yes, Aspose.Cells can load it into an excel file with just a few line of code. If it's not a spreadsheetML file, you can try to:

1. Load the xml file into a DataTable and then use Cells.ImportDataTable method to load it.

2. If it cannot be easily to load into a DataTable, you may have to use your own code to parse it and put the data into Excel file through Aspose.Cells.

Laurence,

I really appreciate your reply.

What i want to know is: should i choose your product instead of finding a free way to dump data into excel (getting data from webservice or datatable/set) ?

kind regards and again thank you very much, Tom.

ps : also consider that i have learned to hate the solution that needs to have excel installed, because it always generates unexplainable errors in my current solution....

Hi,

Thanks for considering Aspose.

Aspose.Cells is a non UI spreadsheet management component that does not require MS Excel to be installed on the system. It has plenty of APIs which can perform all types of tasks.

For the complete list of our product overview, Please see:

http://www.aspose.com/wiki/default.aspx/Aspose.Cells/ProductOverview.html

If you have further queries, contact us any time.

We feel happy supporting customers.

Regards

Amjad Sahi

Aspose Nanjing Team

What i want to know is: should i choose your product instead of finding a free way to dump data into excel (getting data from webservice or datatable/set) ?

I don't know there is a free way to dump data into a native Excel file without MS Excel. If you know some, please let me know. I can also evaluate them.

What Aspose.Cells can offer:

1. An elegant .net solution without MS Excel.

2. Very rich feature set to working on Excel files.

3. Many other useful features related to spreadsheet application.

4. Fast and excellent custom support.

Laurence,

Indeed, i fully agree on point 4 ;)

I don't know there is a free way to dump data into a native Excel file without MS Excel. If you know some, please let me know. I can also evaluate them.

What if i would:

- read data out of a datatable/dataset/xml file/webservice and construct a html table and hardcode the style and save it as .xls

- write pure ExcelML code in code behind (which is a pain if you want to change style)

- do a xslt transformation on a xml file (and thus adding style) and open it in excel.

(all this solutions without using excel.exe to create the result (which i believe is interop, what i rather will not use)

ps : what do you mean exactly with native excel format? biff format ?

please forgive me for being so annoying, but i have to defend the buy of your product.

kind regards, Tom.

Dear Tom,

1. read data out of a datatable/dataset/xml file/webservice and construct a html table and hardcode the style and save it as .xls

Aspose.Cells doesn't support to import/export html now. But I think if you have read data out of a datatable/dataset/xml file/webservice, it's very easy to populate them into an xls file with Aspose.Cells. And it's easy to apply style with code.

2. write pure ExcelML code in code behind (which is a pain if you want to change style)

When you talk about ExcelML, do you mean SpreadsheetML?

When you use Aspose.Cells, it's easy to import/export SpreadsheetML, just a few line of code.

3. do a xslt transformation on a xml file (and thus adding style) and open it in excel.

Aspose.Cells doesn't support this transformation. You have to make it by your own code. It's better to transfer it to a SpreadsheetML file, then Aspose.Cells can easily handle it.

4. what do you mean exactly with native excel format? biff format ?

You are absolutely right.

Laurence,

When i try to create a example excel file with this code : (this export page is called through a javascript callback that is activated by clicking on a html button, so not through postback !)

//start in page load

Workbook workbook = new Workbook();

Worksheet sheet = workbook.Worksheets[0];

sheet.Name = "Grade Table";

sheet.IsGridlinesVisible = false;

Cells cells = workbook.Worksheets[0].Cells;

cells["E4"].PutValue("ASPOSE School District");

workbook.Save("Mediacodes.xls", FileFormatType.Default, SaveType.OpenInBrowser, HttpContext.Current.Response);

// in page load

i get a security warning bar from IE 7 saying that IE has prevented downloading the file.

After "allowing" through choosing "download file "on the security bar, and reclicking the export button, callback, export page, i get the open/save/cancel dialog. When i choose open, nothing happens.

When i click the export button again, i get a message saying "no such interface supported", caused by te callback javascript.

any thoughts on this ?

kind regards, Tom.

If you want to open an Excel file in IE, we suggest that you put the code in Page_Load event, not in other events or javascript callback. Otherwise you may meet weird problem. I don't know why but it seems that's an IE issue.

You can replace your code with following piece of code:

FileStream fs1 = new FileStream("d:\\invoice.xls", FileMode.Open, FileAccess.Read);
byte[] data1 = new byte[fs1.Length];
fs1.Read(data1, 0, data1.Length);

HTTPResponse response = HttpContext.Current.Response
response.ContentType = "application/xls";
response.AddHeader( "content-disposition","inline; filename=book1.xls");
response.BinaryWrite(data1);
response.End();

Above code read an xls file and send it to Response object. You can try it to see if it shows the same problem.

Laurence,

I can really appreciate your fast support.

The code that you gave, is starting from a existing .xls. (= ideal for when i have difficult layouts ?)

I would like to generate it from scratch through an export button on the page without posting back the page (seems cleaner).

kind regards, Tom.

My sample code is just to help you figure out if this problem is caused by IE. It doesn't matter with Aspose.Cells. If it works for you, with Aspose.Cells you can try following code:

Workbook wb = new Workbook();

//Create your Excel file here.

......

MemoryStream stream = new MemoryStream();

wb.Save(stream, FileFormatType.Excel2003);

byte[] data1 = stream.ToArray();

HTTPResponse response = HttpContext.Current.Response
response.ContentType = "application/xls";
response.AddHeader( "content-disposition","inline; filename=book1.xls");
response.BinaryWrite(data1);
response.End();