470,647 Members | 1,061 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,647 developers. It's quick & easy.

Office Web Components - Text Formating

Ken
I need to know the correct syntax for formatting a cell as
text.

Using the Office XP Web Components in an ASPX page, the
following code creates a simple two cell spreadsheet and
saves it to disk. So far so good. My data has long account
numbers that have leading zeros, so I need to format the
some cells as text to preserve the data. The
second ".NumberFormat" statement does not runtime error,
however, when I open the sheet it says 'HTML Import
Errors' -> 'HTML ERROR in Number Format : Text'

I need to know the correct syntax for formatting a cell as
text.
-----------------------------------------------------------
Dim XLS As New OWC10.SpreadsheetClass()
Dim Sheet As OWC10.Worksheet = XLS.ActiveSheet
Dim ThisRange As OWC10.Range
Sheet.Cells(1, 1) = "99.95"
Sheet.Cells(1, 2) = "001212012"
ThisRange = Sheet.Range(Sheet.Cells(1, 1), Sheet.Cells(1,
1))
ThisRange.EntireColumn.NumberFormat = "#,##0.00"
ThisRange = Sheet.Range(Sheet.Cells(1, 2), Sheet.Cells(1,
2))
ThisRange.EntireColumn.NumberFormat = "Text"
XLS.Export("C:\MyExcel.xls", ssExportActionNone,
ssExportHTML)
-----------------------------------------------------------

Jul 19 '05 #1
1 5322
"Ken" <an*******@discussions.microsoft.com> wrote in message
news:00****************************@phx.gbl...
I need to know the correct syntax for formatting a cell as
text.

Using the Office XP Web Components in an ASPX page, the
following code creates a simple two cell spreadsheet and
saves it to disk. So far so good. My data has long account
numbers that have leading zeros, so I need to format the
some cells as text to preserve the data. The
second ".NumberFormat" statement does not runtime error,
however, when I open the sheet it says 'HTML Import
Errors' -> 'HTML ERROR in Number Format : Text'

I need to know the correct syntax for formatting a cell as
text.
-----------------------------------------------------------
Dim XLS As New OWC10.SpreadsheetClass()
Dim Sheet As OWC10.Worksheet = XLS.ActiveSheet
Dim ThisRange As OWC10.Range
Sheet.Cells(1, 1) = "99.95"
Sheet.Cells(1, 2) = "001212012"
ThisRange = Sheet.Range(Sheet.Cells(1, 1), Sheet.Cells(1,
1))
ThisRange.EntireColumn.NumberFormat = "#,##0.00"
ThisRange = Sheet.Range(Sheet.Cells(1, 2), Sheet.Cells(1,
2))
ThisRange.EntireColumn.NumberFormat = "Text"
XLS.Export("C:\MyExcel.xls", ssExportActionNone,
ssExportHTML)
-----------------------------------------------------------


@
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Goran Radivojevic | last post: by
1 post views Thread by gevayl | last post: by
reply views Thread by sundeep | last post: by
2 posts views Thread by csgraham74 | last post: by
1 post views Thread by Greg Smith | last post: by
tolkienarda
12 posts views Thread by tolkienarda | last post: by
reply views Thread by shapper | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.