Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to set the format of cells after importing into Excel
I got the answer.
Set the Value2 property by a 2D array of objects, instead of a 2D array of strings. "Alok" wrote: Like this Worksheet.Range("A1:A20").NumberFormat = "0.00" However, if setting the format in Excel itself is not having an effect on the data you have imported into excel then the above approach will not work. One method to fix the problem when numbers are not treated as numbers is to programmatically do the equivalent of Copy and PasteSpecial and using the add option to add 0(zeor). However since your range - the range you import - consists of both numbers, text etc, I am not sure what effect this will have unless you can identify the ranges that are specifically numbers and apply the above method only on them. Alok "zhaounknown" wrote: I have an 2D array of data, and import into Excel by using Range.Values2=2DArray (C#). The problem is: some data are number, some data are datetime, some data are text, but all the data in the resulting excel file is treated to be text. That is, data seems to be number in a cell, but it is not actually. Furthermore, it can't be reformted by using Excel's menu: Format Cells, unless you reenter the data manually. The data will be taken as number. My question is, how can I programmingly set the format of a range. (Not of a cell). Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Keep Font format when importing excel into Access | Excel Discussion (Misc queries) | |||
Excel Changes Text Cells to Number Cells When Importing XML | Excel Discussion (Misc queries) | |||
Importing multiline records files into Excel cells | Excel Discussion (Misc queries) | |||
importing another file format into Excel | Excel Discussion (Misc queries) | |||
Importing Word Paragraph to Excel - 1 cell, same formating -- I lose the format | Excel Programming |