views:

358

answers:

3

Hi

I would like to output a table to a webpage. The table is stored in an excel sheet (xls).

Is it possible to use xslt for this? The table is the cells are in this range: A26 - P36 (16 columns and 11 rows)

If an exmaple file is need here is a link: http://finans.opengate.dk/media/6704/2010-01-13.xls

Update: A daily file is uploaded. And I would like to automatically show a table from the latest xls-file using xslt. If some C# is needed to convert it from excel to something else (XML?) that is fine. It is done in the CMS Umbraco and that is why I hope to use XSLT since that is the way to show things in Umbraco, through xslt makroes.

BR. Anders

UPDATE with answer (based on answers below): No, it is not possible to read xls-files using xslt. If needed then one has to save excel sheet in another format xml or html. Or one will need a real programming language to read the excel file.

+1  A: 

XSLT is mostly used to convert XML from one dialect to another, not to convert xls files to html.

If you just want to do this manually, you can save your worksheet as HTML directly in excel.

It is not clear from your question if you want to do this programmatically, and if so using what programming language.

Oded
Thanks for your feedback. I just updated question with the info that I would like to have it done automatically. And that if xslt cannot read xls then some C# code can be used for the job or just to convert xls to xml
Tillebeck
A: 

You can use ADO.net to access cells in an excel file, similar to a DB query. This is a bit lighter than trying to use Excel automation objects.

http://support.microsoft.com/kb/316934

Paddy
thanks for the link. I will come back to it. But is it correct that it is about code going into the excel sheet? If possible in any way I would love to make the xslt ablo to retrieve the data from an xls-file. But if not possible another solution must be made.
Tillebeck
As said above, you could save your worksheet as another format, but otherwise you will need to do some programming. Of course, you could just server the excel file directly...
Paddy
A: 

SpreadsheetGear for .NET can read Excel files and display them in a DataGrid as shown in the Excel to DataGrid sample on this page:

    // Create a workbook from an Excel file
    String ssFile = Server.MapPath("files/spiceorder.xls");
    SpreadsheetGear.IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook(ssFile);
    // Get a DataSet from an existing defined name
    DataSet dataSet = workbook.GetDataSet("orderrange", SpreadsheetGear.Data.GetDataFlags.FormattedText);
    // Bind a DataGrid to the DataSet
    DataGrid1.DataSource = dataSet;
    DataGrid1.DataBind();

SpreadsheetGear can also render png/gif/jpg images from cell ranges or charts as demonstrated here.

You can download the free trial here if you want to try it yourself.

Disclaimer: I own SpreadsheetGear LLC

Joe Erickson
Thanks for the tip. I cannot do any C#, so some company will have to do that part. I will send them the link to this thread so they will get to know your product. Hope sales are doing well ;-)
Tillebeck