Export data in a web application to Excel including formulas for columns

Do you write web applications for intranet applications? Have your users ever asked for the ability to export a certain report to excel? Do they complain about formulas not being there?

I do a lot of web applications that deal with HR stuff on the intranet (I can assume my users have Internet Explorer and Excel 2002 on their machines). With HR there are formulas for almost everything and when they get a spreadsheet of useful information without formulas, it suddently isn't so useful anymore (takes them too long to go and put the formulas in).

Thanks to Microsoft's Office getting on the HTML bandwangon so soon (Office 2000 and above), I can "export" data from a web application to excel with the formulas. To the user, it is an export. Really it isn't, it is only an HTML page with certain XML tags in it that Excel will interprete for the user into formuals, font formats, etc. If you put the proper headers on the page, Internet Explorer will tell Excel to open the HTML page and do its magic. So if you have a spread sheet that needs to be exported with formulas, the best place to start is in Excel. Create the spreadsheet you want your application to create and then Save As Web Page. Open this file (html) and check out the source. Now all you need to do is write the code to generate that file and tell IE it is for Excel and you are all set. Here is a little summary of the pieces involved:

Pieces of an excel spreadsheet with formulas

  1. HTML head - with proper namespaces imported
     <html xmlns:o="urn:schemas-microsoft-com:office:office"
      xmlns:x="urn:schemas-microsoft-com:office:excel"
      xmlns="http://www.w3.org/TR/REC-html40">
     <head>
      <meta http-equiv=Content-Type content="text/html; charset=windows-1252">
      <meta name=ProgId content=Excel.Sheet>
      <meta name=Generator content="Microsoft Excel 11">
    

  2. Declare your style
    <style id="STI_5961_Styles">
    <!--
    table
     {mso-displayed-decimal-separator:"\.";
     mso-displayed-thousand-separator:"\,";}
    .xlGeneral
     {padding-top:1px;
     padding-right:1px;
     padding-left:1px;
     mso-ignore:padding;
     color:windowtext;
     font-size:10.0pt;
     font-weight:400;
     font-style:normal;
     text-decoration:none;
     font-family:Arial;
     mso-generic-font-family:auto;
     mso-font-charset:0;
     mso-number-format:General;
     text-align:general;
     vertical-align:bottom;
     mso-background-source:auto;
     mso-pattern:auto;
     white-space:nowrap;}
     ...
    </style>
    -->
    
  3. Close the head section and define the table with its cols
    </head>
    <body>
     <div id="STI_5961" align=center x:publishsource="Excel">
    
    <table x:str border=0 cellpadding=0 cellspacing=0 width=2020 style='border-collapse: collapse;table-layout:fixed;width:1518pt'> <col width=147 style='mso-width-source:userset;mso-width-alt:5376;width:110pt'> <col width=55 style='mso-width-source:userset;mso-width-alt:2011;width:41pt'> ...
  4. Create your header tr
      <tr class=xlGeneralBold height=51 style='mso-height-source:userset;height:38.25pt'>
         <td height=51 class=xlGeneralBold width=147 style='height:38.25pt;width:110pt'>Associate  
          Name</td>
         <td class=xlGeneralBold width=55 style='border-left:none;width:41pt'>Rating</td>
       ...
     </tr>
    
  5. Loop through the data and output the table data building a tr for each record
     <tr height=17 style='height:12.75pt'>
       <td height=17 class=xlGeneral style='height:12.75pt'>NOVOSELIC, CHRIS</td>
       <td class=xlGeneral align=right x:num>2</td>
       ...
     </tr>
    
  6. In the correct area add the SUM function code
     ...
     <td class=xlSumDollar x:num="146751.2408" x:fmla="=SUM(A1:A6)"><span style='mso-spacerun:
      yes'> </span>$<span style='mso-spacerun:yes'> </span>146,751.24 </td>
     ...
    
  7. Finish off the body of the page
         </table>
        </div>
      </body>
    </html>
    
  8. Set the content type to tell Internet Explorer to use Excel for this file
    Response.ContentType = "application/vnd.ms-excel";
    
  9. Optional - add the header to tell Internet Explorer to treat the file as an attachment (should prompt user to save or open)
    Response.AddHeader("Content-Disposition", "attachment; filename=SPQ.xls;");
    

No playing around with the Excel object (on the server?!?) ... let Excel do the work for you on the client..

posted on Saturday, March 20, 2004 6:43 AM

Feedback

# Take Outs for 20 March 2004

You have been Taken Out -- see comments in the linked document. Thanks for the post!
3/20/2004 3:15 AM | Enjoy Every Sandwich

# re: Export data in a web application to Excel including formulas for columns

Nice touch adding the formulas. Most of the exports I've seen only send out the calculation results.
3/21/2004 1:52 PM | Darrell

# re: Export data in a web application to Excel including formulas for columns

I am working on getting jasonhaley.com up, whenever that happens, I'll put some sample code up there. I have an entry about doing stuff with Word that I'll try to right this week too.
3/22/2004 1:42 AM | Jason Haley

# Skapa Excel, inklusive formler, på klient via ASP.NET

Det här nog en av de bästa exemplen jag har sett på hur man skapar Exceldokument på klienten, med hjälp av ASP.NET. (Naturligtvis går det lika lätt att använda ASP eller något annat system också.) Formlerna är nog det enda
3/22/2004 4:35 AM | Dag König

# Excel Writer Library

Excel Writer Library
4/1/2004 11:51 PM | Jason Haley

# re: Export data in a web application to Excel including formulas for columns

I want Save Options Such as 1.Open The Excel file from the Current Loaction
2.Save it To Disk


How It Is Possible How to write The code for This Please Give me the solution
4/11/2004 7:02 PM | Ranjani

# re: Export data in a web application to Excel including formulas for columns

Ranjani, the last step that:

Response.AddHeader("Content-Disposition", "attachment; filename=<filenamehere>.xls;");

Will display the prompt I think you are talking about.
4/12/2004 2:40 AM | Jason Haley

# re: Export data in a web application to Excel including formulas for columns

Has anyone experienced a problem performing calculations on data with excel 2000 or above when using the above method to create an excel spreadsheet?

5/5/2004 12:30 AM | Jason

# re: Export data in a web application to Excel including formulas for columns

Jason: what sort of calculations are you doing? The goal is to basically to create your output first and then write an application that create that. If you give me more information on what you are doing I can probably help.
5/5/2004 1:10 AM | Jason Haley

# re: Export data in a web application to Excel including formulas for columns

We have various columns with sales dollars, cost, qty, etc. Occassionally we have a user who would like to perform simple sum or multiplication calculations on some of these values. Unfortunately this is a random occurance other wise the app could be modified to accomodate these calculations.

In excel 97 users are able to perfrom calculations, however excel 2000 or above returns an error.
5/5/2004 1:19 AM | Jason

# re: Export data in a web application to Excel including formulas for columns

Jason: When you originally created the HTML did you do it in Excel 97 or 2000? I seem to have had the reverse situation of yours. I did mine in 2000 and some people had problems with it on 97. You might need to use a different style sheet for one and a different for the other. May give the user the option to download for excel 97 or excel 2000?

I would start with taking the output in excel on 97 save as a web page, then do the same with excel 2000 and see what the differences are.

What is the error they are getting?
5/5/2004 2:54 AM | Jason Haley

# re: Export data in a web application to Excel including formulas for columns

Formula reference in example dosen't work- x:fmla="=SUM(R106)".
Excel expect cell reference in A1 notation not in R1C1, maybe you find out how to turn on R1C1 notation?
5/18/2004 4:17 AM | Andrey Skvortsov

# re: Export data in a web application to Excel including formulas for columns

Andrey: You are right. The cell referenced in the sample code looks like a typeo to me (as you pointed out), but looking at where I got it is actually just plugging in the value of the cell R102 to the cell that I was printing out.

To get the sum of A1 + A2 you would need to put "=SUM(A1:A2)" in for the formula. I will change the example above to show this instead, it is a little more clear that way.
5/18/2004 4:24 AM | Jason Haley

# re: Export data in a web application to Excel including formulas for columns

Hi,

How do I format a cell data in date format. Is there a x:date tag or something like that?

6/3/2004 7:00 PM | Anirban

# re: Export data in a web application to Excel including formulas for columns

Anirban: Excel uses what they call a serial date. Check out this article on CodeProject to find out how to calculate it: http://www.codeproject.com/datetime/exceldmy.asp

Use a css class something like this:

.xl24 {mso-style-parent:style0;mso-number-format:"Short Date";}

Once you have the serial date, you can use the following to display a date in a cell:
<td class=xl124 align=right style='width:62pt' x:num="38142">6/4/2004</td>
6/4/2004 12:57 AM | Jason Haley

# re: Export data in a web application to Excel including formulas for columns

hi, I want to keep the number in the table formatted as text when I saved it to excel.

Is there a tag for that? Where can I find a description of all tags that are avaliable?

Thks!
6/10/2004 4:51 PM | Gape

# re: Export data in a web application to Excel including formulas for columns

Gape: Check out http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexcl2k2/html/odc_xmlss.asp?FRAME=true#odc_xmlss_ss:Workbook for a good reference of the xml schema.

Best way to find out how to format a number as text in the html is to do it in Excel then File -> Save as web page. Then check out the html that excel writes. Should look something like:

Number:
<td x:num>1</td>

String:
<td x:str="'1">1</td>
6/11/2004 4:12 AM | Jason Haley

# re: Export data in a web application to Excel including formulas for columns

HI,
How to add multiple worksheets in this? Also I need to add some images, could you please guide?

thanks!

Sachin
6/15/2004 10:20 AM | Sachin

# re: Export data in a web application to Excel including formulas for columns

I a nice article but the only thing is that it dosen't works in excel 97.Actually i export the page and when i try to open it in excel it's comming with HTML content (all tags)
in the excel .Can you give any resons for that.
7/1/2004 9:01 PM | sanjay joshi

# re: Export data in a web application to Excel including formulas for columns

Sanjay: The above mentioned Excel Export only works well with Excel 2000, XP, 2003 or better. I too have had problems with Excel 97, so I upgraded. Sorry don't know any way around that one...
7/3/2004 7:44 AM | Jason Haley

# re: Export data in a web application to Excel including formulas for columns

Is it possible to open an existing excel file and add the data to the [Sheet1] ? Any suggestions are greatly appreciated. TIA.
7/15/2004 3:04 AM | anony:

# re: Export data in a web application to Excel including formulas for columns

anony: The only way to efficiently open an "excel" file is going to be if it is already really and html file (like the method above creates). Then you can edit it just like any other html file. In my opinion there is not a good way to edit any excel or word files on the server. Microsoft Office is built to be a client application, so you have to come up with work arounds or buy 3rd party products to create a server solution. If you find a way other than a work around, please let me know.
7/15/2004 3:09 AM | Jason Haley

# Export data in a web application to Excel including formulas for columns

Source: Jason Haley Ramblings of a .Net Developer Export data in a web application to Excel including formulas for columns Do you write web applications for intranet applications? Have your users ever asked for the ability to export a certain
8/28/2004 11:11 AM | Dewayne and Shadow his Webdog

# re: Export data in a web application to Excel including formulas for columns

cool
9/23/2004 10:28 PM | Charmaine

# re: Export data in a web application to Excel including formulas for columns

Can anyone tell me how to export the contents of a control (ex. repeater, datagrid ) in 2 worksheets? the first worksheet contains the datagrid and the second worksheet has the repeater. Both will be exported in the same file.
9/23/2004 10:31 PM | Charmaine

# re: Export data in a web application to Excel including formulas for columns

http://dotnetjunkies.com/WebLog/stefandemetz/archive/2004/10/01/27337.aspx
10/1/2004 11:23 AM | stefan demetz

# re: Export data in a web application to Excel including formulas for columns

Hi All,

it might be very trivial question, I'm using same concept in Domino.

Problem I'm facing is when I first time click on the button to generate report (in Excel), it works fine, but when I click second time it does not open it in new window, it tries to open it in same window.

How can I control that? (I do not have option of using <a> tag with Target attribute).

Please help.


Sid
10/22/2004 3:44 AM | Sid

# re: Export data in a web application to Excel including formulas for columns

Can anyone provide me example how to write huge sql server data to Excel. I am using asp.net and code behind is vb.net
10/27/2004 8:58 AM | Temp

# re: Export data in a web application to Excel including formulas for columns


Once you have set the content type,how does IE use excel to do calculations?do i change set content type in source code or do it using dreameaver/frontpage etc does it have to be xml file or can it be html.very much appreaicated if u can help

PS sorry my knowledge is'nt very good
11/30/2004 3:59 AM | ahmed

# re: Export data in a web application to Excel including formulas for columns

Hi,

I'm currently trying to implement something like this. However, I've encountered a problem. One of my reports needs to show two tables side-by-side in Excel, but I have to generate the rows for each table independtly. My first thought was to use tables-within-a-table in the HTML source, but it seems that Excel loses the column widths (i.e., the column widths change from what I've set them to before) when I try to create a new table inside one of the existing <td>s

Any idea how this can be done? Or maybe someone can point me to online resources that might help?

Thanks,

Roy
(gmail: roytang)
12/22/2004 12:14 AM | Roy

# re: Export data in a web form to Excel Rows or columns and whole text.

I am looking for one export functionality ... in which I will click one export button and that web form should save as excel. Thats all.
Thank you
tushar
Bangalore India
reply me on tusharkashyap@yahoo.com
12/23/2004 4:05 PM | Tushar

# re: Export data in a web application to Excel including formulas for columns

Using the serial date worked perfectly. Thank you for the additional information. However, I need to format the date and time. I noticed that EXCEL used a fraction to represent the time in the serial date, so did the following:
Used this format: mm\/dd\/yyyy\\ h\:mm\\ AM\/PM
Appended the "time" as a fraction to the serial date such as x:num=38142.25

Any assistance or recommendations you may be able to provide on displaying the Date/Time would be greatly appreciated.
2/9/2005 3:10 AM | Lynda

# re: Export data in a web application to Excel including formulas for columns

Excel 2003 is exporting me all html tags while excel 2000 is working fine.
As mentioned here it should work on all excel above 2000.
anyone knows if something should be changed?
3/7/2005 12:03 AM | yanai

# re: Export data in a web application to Excel including formulas for columns

Superb idea that simply amazing!!!
3/9/2005 9:28 PM | coolitsam

# re: Export data in a web application to Excel including formulas for columns

Great job. This is the piece of code I was looking for

Response.AddHeader("Content-Disposition", "attachment; filename=SPQ.xls;");
3/16/2005 5:23 AM | Syed Shariq Zeeshan

# re: Export data in a web application to Excel including formulas for columns

Great code. Do you know how to export the datagrid to excel with the header on top of each page?

Thanks
ptn
4/13/2005 3:59 AM | ptn

# Export Image to Excel from ASP.Net

Hi,

I need to add some images, could you please guide?

Thanks a Lot in adv
Godfrey
4/13/2005 5:57 PM | Godfrey

# re: Export data in a web application to Excel including formulas for columns

I have an asp.net page where users can download datagrid to excel sheet. Its working fine but there is an issue. I have a char field on the grid which may or may not have zero's in front. The problem is when I download this sheet to excel, It ignore zero's. For example if its showing 01567 in a cell in the datagrid, it will download this number as 1567 to excel.

I tried to add styles as

DataGrid1.DataBind()
Dim strStyle As String = "<style>.text { mso-number-format:Text; } </style>"
For intTemp As Integer = 1 To ds.Tables(0).Rows.Count - 1
DataGrid1.Items(intTemp).Cells(0).Attributes.Add("class", "text")
Next

But when user click on a button to download the datagrid to excel, it still ignoring zero's. Here is the code to download to excel. So after downloading to excel, it's still downloading 0067 as 67.

4/19/2005 5:59 AM | Jus55

# Is the same above applicable using PHP

Pieces of an excel spreadsheet with formulas

HTML head - with proper namespaces imported
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 11">



Declare your style
<style id="STI_5961_Styles">
<!--
table
{mso-displayed-decimal-separator:"\.";
mso-displayed-thousand-separator:"\,";}
.xlGeneral
{padding-top:1px;
padding-right:1px;
padding-left:1px;
mso-ignore:padding;
color:windowtext;
font-size:10.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:Arial;
mso-generic-font-family:auto;
mso-font-charset:0;
mso-number-format:General;
text-align:general;
vertical-align:bottom;
mso-background-source:auto;
mso-pattern:auto;
white-space:nowrap;}
...
</style>
-->

Close the head section and define the table with its cols
</head>
<body>
<div id="STI_5961" align=center x:publishsource="Excel">

<table x:str border=0 cellpadding=0 cellspacing=0 width=2020 style='border-collapse:
collapse;table-layout:fixed;width:1518pt'>
<col width=147 style='mso-width-source:userset;mso-width-alt:5376;width:110pt'>
<col width=55 style='mso-width-source:userset;mso-width-alt:2011;width:41pt'>
...

Create your header tr
<tr class=xlGeneralBold height=51 style='mso-height-source:userset;height:38.25pt'>
<td height=51 class=xlGeneralBold width=147 style='height:38.25pt;width:110pt'>Associate
Name</td>
<td class=xlGeneralBold width=55 style='border-left:none;width:41pt'>Rating</td>
...
</tr>

Loop through the data and output the table data building a tr for each record
<tr height=17 style='height:12.75pt'>
<td height=17 class=xlGeneral style='height:12.75pt'>NOVOSELIC, CHRIS</td>
<td class=xlGeneral align=right x:num>2</td>
...
</tr>

In the correct area add the SUM function code
...
<td class=xlSumDollar x:num="146751.2408" x:fmla="=SUM(A1:A6)"><span style='mso-spacerun:
yes'> </span>$<span style='mso-spacerun:yes'> </span>146,751.24 </td>
...

Finish off the body of the page
</table>
</div>
</body>
</html>

What code should be used in php to do the same?
**********************************************
{Set the content type to tell Internet Explorer to use Excel for this file
Response.ContentType = "application/vnd.ms-excel";

Optional - add the header to tell Internet Explorer to treat the file as an attachment (should prompt user to save or open)
Response.AddHeader("Content-Disposition", "attachment; filename=SPQ.xls;");}

4/21/2005 7:43 PM | josna

# re: Export data in a web application to Excel including formulas for columns

This article helped me to export HTML data to Excel. I need more features. For ex: i want some header and footer info get repeated in each page in excel, page size set to landscape etc... Also, some columns doesn't seem to have proper width and some columns aren't having enough space to hold the data. What currently i'm doing is: i do all above formatting manually in excel after downloading. I want my Excel data look exactly like HTML data that is shown on the browser. Pls help me to implement the above functionality.

Thank you so much.
4/24/2005 9:47 PM | Laxmi

# re: Export data in a web application to Excel including formulas for columns

very nice weblog... helpful
4/26/2005 10:20 PM | thuc

# re: Is the same above applicable using PHP

This worked to get example to function with php

=======================================================

<?php
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=extraction.xls");
header("Pragma: no-cache");
header("Expires: 0");
?>

<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=Generator content="Microsoft Excel 11">

<style id="STI_5961_Styles">
table
{mso-displayed-decimal-separator:"\.";
mso-displayed-thousand-separator:"\,";}
.xlGeneral
{padding-top:1px;
padding-right:1px;
padding-left:1px;
mso-ignore:padding;
color:windowtext;
font-size:10.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:Arial;
mso-generic-font-family:auto;
mso-font-charset:0;
mso-number-format:General;
text-align:general;
vertical-align:bottom;
mso-background-source:auto;
mso-pattern:auto;
white-space:nowrap;}
</style>

</head>
<body>
<div id="STI_5961" align=center x:publishsource="Excel">

<table x:str border=1 cellpadding=0 cellspacing=0 width=2020 style='border-collapse:
collapse;table-layout:fixed;width:1518pt'>
<col width=147 style='mso-width-source:userset;mso-width-alt:5376;width:110pt'>
<col width=55 style='mso-width-source:userset;mso-width-alt:2011;width:41pt'>

<tr class=xlGeneralBold height=51 style='mso-height-source:userset;height:38.25pt'>
<td height=51 class=xlGeneralBold width=147 style='height:38.25pt;width:110pt'>Associate Name</td>
<td class=xlGeneralBold width=55 style='border-left:none;width:41pt'>Rating</td>
</tr>

<tr height=17 style='height:12.75pt'>
<td height=17 class=xlGeneral style='height:12.75pt'>NOVOSELIC, CHRIS</td>
<td class=xlGeneral align=right x:num>2</td>
</tr>

<tr height=17 style='height:12.75pt'>
<td height=17 class=xlGeneral style='height:12.75pt'>NOVOSELIC, JOE</td>
<td class=xlGeneral align=right x:num>3</td>
</tr>

<tr height=17 style='height:12.75pt'>
<td height=17 class=xlGeneral style='height:12.75pt'> </td>
<td class=xlSumDollar x:num="146751.2408" x:fmla="=SUM(B2:B3)"><span style='mso-spacerun:yes'> </span>$<span style='mso-spacerun:yes'> </span>146,751.24 </td>
</tr>

</table>
</div>
</body>
</html>
5/11/2005 10:35 AM | corefire

# Note on getting correct html format

A note about getting the right html stuff for excel.

If you create the document you want in excel spread sheet and save in html format it will give you the exact html formatting like above. you can then write code that dynamicaly fills in the correct data for diffrent areas.

Furter note, muliple sheets in excel export to multiple documents, if you want it all in one file need to use one sheet.

Just some tips i found while working on it.
5/11/2005 4:59 PM | corefire

# re: Export data in a web application to Excel including formulas for columns

If i need to open the excel file as a csv file in a new browser window & not in the same window & not get a dialog box to open/ save; how can it be done?
5/17/2005 12:41 AM | Gash

# re: Export data in a web application to Excel including formulas for columns

Anyone know how to insert a line break with in an excel cell. Everything I've tried creates a new row where the line break should be.
5/23/2005 9:21 AM | Kevin Dew

# re: Export data in a web application to Excel including formulas for columns

sdf
7/25/2005 6:44 AM | sd

# re: Export data in a web application to Excel including formulas for columns

Hi,

I am trying to export data to OpenOffice calc spreadsheet. Report is generated, however, It is not taking rowspan more than 256. So, report format get spoiled. Also, style is not getting applied.
8/6/2005 12:22 AM | amol

# How to export datagrid to excel along with sum formula in datagrid's footer???

I've exported datagrid of asp.net into excel.
Footer of the datagrid shows summation of all the records.
now, I want that, when i export page in excel the footer cell should have sum formula of excel to be applied.
Any suggestion?????
9/2/2005 2:51 AM | Bhanu

# re: Export data in a web application to Excel including formulas for columns

We have a web application where our field people enter their Sales Data. There is a consolidated report option in the application. I want to add the Export to Excel option in that report so that I can take it out in Excel and do any formatting that I want. Our backend is SQL Server and front-end is ASP page. Any help with the codes since I am a newbie.
4/11/2006 4:16 AM | I Guha

# re: Export data in a web application to Excel including formulas for columns

The image don't appear in the file exported.
5/8/2006 12:03 PM | Leandro

# Export data in a web application to Excel including formulas for columns

I have found two types of conditional formula exports for excel 9.

1 Format
<td class=xl11318521 style='border-top:none;border-left:none'
x:num="-0.1158925665616453"
x:fmla="=IF(D8&lt;10.001,D8/10*O63*C53,IF(AND(D8&gt;10,D8&lt;50.001),O63*C53+(S63-O63)/40*(D8-10)*C53))">-0.12</td>

2 Format
<td class=xl11116731 style='border-top:none;border-left:none'
x:num="-0.1158925665616453"
x:fmla="=(D8 < 10.001 ? (D8 / 10 * O63 * C53) : (D8 > 10 && D8 < 50.001 ? )O63 * C53 + (S63 - O63) / 40 * (D8-10) * C53) : 0))">-0.12</td>

Can someone tell me how I can export excel html in this second formula format.

Thanks.
5/14/2006 10:54 PM | D

# re: Export data in a web application to Excel including formulas for columns

hi

i am facing a problem . the problem is that
i want a button on my web page and on clicking that button all the results i have on the web page should go to excel sheet and i want the code to be in html or vb script or any other scripting language(preferably in html or vb script) thank u
5/26/2006 1:53 AM | manjunath

# re: Export data in a web application to Excel including formulas for columns

I need to export a datagrid to WORD. I need legal notice footers to appear on every page. I know I can export to WORD in a similar fashion mentioned here for EXCEL but how do I open an existing WORD doc or WORD template so my resulting document will contain the necessary footers??? TIA....
6/1/2006 8:01 AM | rmorelli

# re: Export data in a web application to Excel including formulas for columns

Hi,
Though I am a Java Developer, the code for exporting to excel with formulas was quite help full for me too.
Is there any way though which we can give auto filter option through code in excel.

Regards :) sandeep

6/3/2006 5:28 AM | Sandeep Virmani

# re: Export data in a web application to Excel including formulas for columns

Hi,
Can anybody say me, how is it possible to associate a external CSS stylesheet when exporting a excel document from ASp.NET application. I am able to get all the data exported to excel document but only stylesheet is not getting applied. Please let me know at earliest
8/10/2006 11:29 PM | Affy

# re: Export data in a web application to Excel including formulas for columns

I am facing problem when exporting data from datagrid to excel sheet.i.e I have date column in datagrid,that date is not correctly displaying with excel sheet.Example i have 06/june/2006 in datagrid, but it showing in excelsheet as 6/june/06.please help me .Thanks in advance.
8/16/2006 12:30 AM | Goutam

# re: Export data in a web application to Excel including formulas for columns

Hi,

We have a web application which have some reports option,and we want to add export to excel button ,when it is clicked the result from web page should go to excel.The application is developed using struts1.1,back-end oracle.

Any body having code for this logic,please help me.

Thanks in advance.
8/19/2006 4:38 AM | Sri

# re: Export data in a web application to Excel including formulas for columns

hi
i want to export a num from datagrid to excel sheet ....and that number starts from 00.....i mean 0034267...get converted to 34267 in excel sheet ...but i want 0034267 in excel sheet ....

plz help me
9/12/2006 12:15 AM | prya

# re: Export data in a web application to Excel in multiple sheets/tabs

Hi,

I have a problem where I need to export data into multiple sheets/tabs in one excel file. Is it possible to do so in ASP with vbscript? I need to do so because I have too much records (more than 90000) so it won't fit in 1 sheet of excel file. Anyone please help me~ thank you.
9/25/2006 8:18 PM | richo

# re: Export data in a web application to Excel including formulas for columns

asdfasdfsd
11/27/2006 3:38 AM | sdfsd

# re: Export data in a web application to Excel including formulas for columns

HI...

Can any one help me?

I am exporting data to excel file using asp.net. But I am not able to attache stylesheet to that. I want to apply css to the exported excel file. For your information, I am exporting Data in Table formate which contains DataGrid As well.

It is really urgent.

Thanks,

Chital
11/27/2006 3:44 AM | Chital

# re: Export data in a web application to Excel with same colors as gridview is having

hi, i'm facing a problem. Actually i've to export a web page(.aspx) to excel but with the same formatting as that of the webpage. the webpage is having gridview, with a stylesheet applied. But when i export , the color of data in excel which comes from gridview is not same as tht was in gridview. Plz help me if anybody knows abt it. It's very urgent to me. So plz as soon as possible plz help me out
12/7/2006 7:19 AM | Michel

# re: Export data in a web Export data in a web application to Excel in multiple sheets/tabs

I have a problem where I need to export data into multiple sheets/tabs in one excel file. Is it possible to do so in ASP with vbscript? I need to do so because I have too much records (more than 90000) so it won't fit in 1 sheet of excel file. Anyone please help me~ thank you.
1/16/2007 2:42 AM | sanjay

# re: Export data in a web application to Excel including formulas for columns

wonderful!
4/12/2007 1:27 PM | MB

# re: Export data in a web application to Excel including formulas for columns

The value "23429110140706" in datagrid column, is being displayed as "2.34291E+13
" in the excel sheet. I want to retain "23429110140706" in excel sheet as well. Can someone please help me with this??

Prash..
7/2/2007 2:38 AM | Prash..

# re: Export data in a web application to Excel including formulas for columns

Solution for line break issue. Simply add the following item in the Style section of the HTML.
<style>
...
br {mso-data-placement:same-cell;}
...
</style>

Credit to:
http://weblogs.asp.net/michu/archive/2004/06/15/155851.aspx
8/23/2007 12:04 PM | pg

# re: Export data in a web application to Excel including formulas for columns

Anyone know how to insert a line break with in an excel cell. Everything I've tried creates a new row where the line break should be
9/3/2007 2:54 PM | seo yarışması

# re: Export data in a web application to Excel including formulas for columns

If you create the document you want in excel spread sheet and save in html format it will give you the exact html formatting like above. you can then write code that dynamicaly fills in the correct data for diffrent areas.
9/3/2007 2:55 PM | kral oyun

# re: Export data in a web application to Excel including formulas for columns

I have all the same issue as everyone else asking about retaining the leading zero or forcing a cell format to "TEXT". I tried the 2 suggestions in the thread from everyone else and it isn't working! I even tried to manually create a page of HTML table codes and set x:str="'00123456789" and u1:str="'00123456789" and it just appears as "123456789" in Excel when I open it in Excel 2007 to check. I been searching for a solution on this for a week!! Someone please help me?

The excel file is beging generated via an ASP pages using Response.write().

thanks in advance!

Julie
9/28/2007 2:20 PM | Julie

# re: Export data in a web application to Excel including formulas for columns

thanks
9/29/2007 3:00 PM | cep telefonu

# re: Export data in a web application to Excel including formulas for columns

When I am exporting a large file from ASP Application to Excel, it gives an error message that file .... not found. Where as it is working fine with small files having less than 5 MB data.
Please suggest me how to resolve this problem
9/30/2007 10:35 PM | Sandeep

# re: Export data in a web application to Excel including formulas for columns

thanks
11/14/2007 2:24 PM | sex shop

# re: Export data in a web application to Excel including formulas for columns

thanks for link
11/14/2007 2:25 PM | sex shop

# re: Export data in a web application to Excel including formulas for columns

thanksss.
11/21/2007 2:23 PM | drcetinerdotorg

# re: Export data in a web application to Excel including formulas for columns

nice article..
11/21/2007 3:24 PM | Tercume

# re: Export data in a web application to Excel including formulas for columns

how to export or include .css files and images when we save excel (.xls) file locally and open the local version in browser.

thanks
12/12/2007 9:37 AM | kumar

# re: Export data in a web application to Excel including formulas for columns

I have a problem where I need to export data into multiple sheets/tabs in one excel file. Is it possible to do so in ASP with vbscript? I need to do so because I have too much records (more than 90000) so it won't fit in 1 sheet of excel file. Anyone please help me~ thank you.
1/26/2008 10:04 PM | automotive repair manual

# re: Export data in a web application to Excel including formulas for columns

Are there a working sample files available for download? If so, can you please pose the url?
2/9/2008 2:24 PM | James Ecker

# re: Export data in a web application to Excel including formulas for columns

I am also having an issue with my ASP.Net Gridview losing Leading zeros when using Excel. My .Net code uses a databound Gridview and I use:

Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""

to have the page display as Excel. I have some Zip codes that have leading Zeros and I cannot figure out how to keep the zeros. So, Zip Code 01234 would display as 1234. How do I use the databound gridview and format the excel column to know it's text and not numeric. I tried creating a style to apply to the ItemStyle of that asp:BoundField, but that didn't work.

Thanks so much in advance for any help

2/22/2008 1:40 PM | Andrew Nadler

# re: Export data in a web application to Excel including formulas for columns

nice resource for webmasters..
2/28/2008 12:45 PM | balık avı

# re: Export data in a web application to Excel including formulas for columns

many Thanks
2/28/2008 12:45 PM | Tonguç Sarp Balyemez

# re: Export data in a web application to Excel including formulas for columns

very nice
3/14/2008 6:36 AM | youtube

# re: Export data in a web application to Excel including formulas for columns

I can't seem to find anyone with the same problem as me.

I have php files that generate that same code up there which creates reports with multiple worksheets perfectly in Excel. But when I open with open office calc, it just shows me a blank spreadsheet.

What changes I can I make to the above code to allow calc to open it?

Thanks a lot...
3/14/2008 12:33 PM | MYHui

# Celdas según tabla - Formulas

Para las formulas la fila debe estar de acuerdo con la tabla no con la fila del Excel, Ejemplo

- Funciona BIEN OK!
<table>
<tr><td>Fila 1</td></tr>
<tr><td>Fila 2</td></tr>
<tr><td>Fila 3</td></tr>
</table>
<table>
<tr><td>30</td></tr>
<tr><td>20</td></tr>
<tr><td x:fmla="=A1/A2"></td></tr>
</table>

-Funciona MAL!!! (No cuadra)
<table>
<tr><td>Fila 1</td></tr>
<tr><td>Fila 2</td></tr>
<tr><td>Fila 3</td></tr>
</table>
<table>
<tr><td>30</td></tr>
<tr><td>20</td></tr>
<tr><td x:fmla="=A4/A5"></td></tr>
</table>





4/4/2008 8:15 AM | Junior Zegarra

# re: Export data in a web application to Excel including formulas for columns

How to export image in excel sheet.
5/30/2008 6:33 AM | Shabbir

# Export to Excel with read only property

I need to export the excel with some columns as read only and some columns can be edited.And i am also want to show the formula for the columns in the header.This need to be done in ASP application.
If anyone have idea please inform me....

Thanks & regards,
Balaji.R
7/28/2008 9:34 PM | balaji.r

Post Comment

Title  
Name  
Url
Comment   
Please enter the following code into the box below to stop spammers

  
Enter Code Here *