473,382 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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 18392

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 &...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.