Office Web Components - Text Formating

K

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)
-----------------------------------------------------------
 
C

Chris Hohmann

Ken said:
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)

@
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top