How To Format Cell as Text Or Date Using Office Web Components Spreadsheet Component?
Posted on 2006-05-11
I'm using Office Web Component to generate spreadsheets.
Example, though VB6
Dim objS as object
Set objS = CreateObject("owc.spreadsheet")
objS.cells(1, 1).Value = "Project"
objS.cells(1, 2).Value = "Tasks Completed"
objS.cells(1, 2).Value = "Last Status Date"
'Add a row of data
objS.cells(2, 1).Value = "MyProject"
objS.cells(2, 2).Value = "5/6" 'Want this to appear in the spreadsheet as a fraction.
objS.cells(2, 2).Value = "2006-05-11 10:21 am" 'Want this to appear as a date and time
objS.activesheet.Export "c:\temp\myspreadsheet.xls", 0
The problem is that my "5/6" value is converted to a date: 6/May. I want to it remain a fraction: 5/6. How can I format the column or cell to be text? I don't want to put an apostrophe in front of the value because a program needs to read the values and import them and I don't want it importing '5/6 instead of 5/6.
The problem with my date is that it's being converted to a number. I want this to remain a date.