473,473 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

When exporting to excel....

....is it the posssible to:

format a field as "currency" or "number"?
format a field as a formula?

I create my sheet as a table
Response.ContentType = "application/vnd.ms-excel"
response.write('<tr><td>blahblah</td></tr>');

is there any other way?

BR
Sonnich

Aug 1 '06 #1
4 18400

Sonnich wrote:
...is it the posssible to:

format a field as "currency" or "number"?
format a field as a formula?

I create my sheet as a table
Response.ContentType = "application/vnd.ms-excel"
response.write('<tr><td>blahblah</td></tr>');

is there any other way?

Yes. Create an .xls file containing the various formats and formulas
you want, then save it as a web page. Open it in an html editor (or
even notepad) and pick about among the various css declarations, paying
attention to things like this: x:num x:fmla="=SUM(A1/B1)" to be found
in td styles. You're sure to find that bits that control formatting
and formulas that way.

When you response.Write your asp, you need to keep all the html that
Excel produces, just making the cell values (or formulas) dynamic.
However, you can run into problems, as I don't believe this produces a
true .xls file. For example, while it appears to act as an .xls file
most of the time, I've had problems in the past getting the Mail Merge
functionality in Word 2003 to recognise it as a genuine .xls file
(although Word 2000 seems to like it :-\).

--
Mike Brind

Aug 1 '06 #2

Sonnich wrote:
...is it the posssible to:

format a field as "currency" or "number"?
format a field as a formula?

I create my sheet as a table
Response.ContentType = "application/vnd.ms-excel"
response.write('<tr><td>blahblah</td></tr>');

is there any other way?
Yes. Here are the styles that I've built up for exactly this purpose:
..currency {mso-number-format:Currency}
..currencybold { mso-number-format:Currency;font-weight:700}

..number0dec {mso-number-format:"0"}
..number2dec {mso-number-format: Fixed;}
..number4dec {mso-number-format:"0\.0000"}
..number6dec {mso-number-format:"0\.000000"}
..number4decbold {mso-number-format:"0\.0000"; font-weight:700}
..number2decbold {mso-number-format: Fixed; font-weight:700;}

..text {mso-number-format:General;text-align:general;white-space:
normal;mso-spacerun: yes }

..textnowrap {mso-number-format:General; text-align:general;white-space:
nowrap; mso-spacerun: yes }

..num2text {mso-style-parent:text; mso-number-format:"\@";white-space:
normal}

..shortdate{mso-number-format:"Short Date"; white-space:normal;}

..MMYY {mso-number-format:"MM/YY"}

..MMDDYY {mso-number-format:"m/d/yy"}

..monthyear {mso-number-format:"\[ENG\]\[$-409\]mmm\\ yyyy\;\@";}

..rotateup {mso-rotate:90}

..excel_bottom_border{border-bottom-style: solid; border-bottom-width:
..5pt}

..excel_top_border{border-top-style: solid; border-top-width: .5pt}

Aug 1 '06 #3

Sonnich wrote:
...is it the posssible to:

format a field as "currency" or "number"?
format a field as a formula?

I create my sheet as a table
Response.ContentType = "application/vnd.ms-excel"
response.write('<tr><td>blahblah</td></tr>');

is there any other way?
I didn't answer all of your questions. For the formula, you don't need
to use the fmla tag. Just put the formula as the cell contents, e.g.

<td>=sum(a1:a4)</td>

Microsoft had documentation on all of this, but when I just searched, I
cannot find it. It's called "Microsoft Office 2000 HTML and XML
Reference".

Aug 1 '06 #4
Larry Bud wrote:
Sonnich wrote:
...is it the posssible to:

format a field as "currency" or "number"?
format a field as a formula?

I create my sheet as a table
Response.ContentType = "application/vnd.ms-excel"
response.write('<tr><td>blahblah</td></tr>');

is there any other way?

Yes. Here are the styles that I've built up for exactly this purpose:

.number0dec {mso-number-format:"0"}
.number2dec {mso-number-format: Fixed;}
.number4dec {mso-number-format:"0\.0000"}
.number6dec {mso-number-format:"0\.000000"}
.number4decbold {mso-number-format:"0\.0000"; font-weight:700}
.number2decbold {mso-number-format: Fixed; font-weight:700;}
Thanks a lot for the other answer, the almost completed my current
task.

At first I did not get this :-) But I got it at last

<STYLE TYPE="text/css"><!--
.number2dec {mso-number-format: Fixed;}
--></STYLE>

and

"<tr><td class=""number2dec"">5,666 blahblah

Thanks a bunch
Sonnich

Aug 2 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ali Eghtebas | last post by:
Hi, I tried this demo application in here (watch for any line breaks in the URL): (http://support.crystaldecisions.com/communityCS/FilesAndUpdates/vbnet_win_a dodotnet.exe.asp When exporting...
3
by: sridevi | last post by:
Hello How to export data from ms-access database to excel worksheet using ASP. mainly i need to export data to multiple worksheets. it is very urgent to us. i have a sample code which works...
2
by: G | last post by:
When I export data from access to excel by with "export" or "Analyze with" I seem to loose parts of some fields (long text strings). Is there a way to export it all to excel? Thanks G
2
by: Kenneth | last post by:
How do I remove the limitation in Access that deny me from exporting 24000 rows and 17 columns (in a query) into Excel? Kenneth
2
by: deko | last post by:
I use a complied query to export to Excel like this: SELECT * INTO . FROM tblExcelData; But I have a situation where I need to export several tables into the same worksheet. The idea is to...
1
by: ad | last post by:
I use the code below to export the content of a data set to Excel, the code come form http://www.dotnetjohn.com/articles.aspx?articleid=36 But it always use the web form's name as the default...
2
by: andrew007 | last post by:
Is there anyway that the page can automatically print while exporting excel from datagrid. My page does exporting to excel from datagrid on the fly but I want to add a feature to print...
2
by: Snozz | last post by:
The short of it: If you needed to import a CSV file of a certain structure on a regular basis(say 32 csv files, each to one a table in 32 databases), what would be your first instinct on how to...
4
by: Tom | last post by:
I have a gridview on all of my web pages in my web app and they all export to excel. I have one page where the gridview is binding to a datatable that i created and only the first column is...
7
by: leninv | last post by:
Hi, I have the following code where 'recs' is a record set. For i=0 to recs.Fields.Count - 1 if i = 0 then pindnt = string(itmlvl*2," ") response.write pindnt &...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.