Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > When exporting to excel....

Reply
Thread Tools

When exporting to excel....

 
 
Sonnich
Guest
Posts: n/a
 
      08-01-2006
....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

 
Reply With Quote
 
 
 
 
Mike Brind
Guest
Posts: n/a
 
      08-01-2006

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

 
Reply With Quote
 
 
 
 
Larry Bud
Guest
Posts: n/a
 
      08-01-2006

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}

 
Reply With Quote
 
Larry Bud
Guest
Posts: n/a
 
      08-01-2006

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".

 
Reply With Quote
 
Sonnich
Guest
Posts: n/a
 
      08-02-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting the datagrid to excel, text and html files. Ravindra ASP .Net 0 12-14-2005 04:14 AM
Mozilla Firefox bookmarks exporting. shaji Firefox 4 09-11-2005 12:41 PM
Exporting and importing Dan Firefox 3 06-17-2005 08:11 AM
Thunderbird exporting Nate Rosenthal Firefox 2 04-06-2005 07:16 PM
Exporting data in Modelsim?? SD VHDL 5 02-23-2005 07:41 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57