Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Keep Font format when importing excel into Access garvic82 Excel Discussion (Misc queries) 1 June 4th 10 08:46 PM
Excel Changes Text Cells to Number Cells When Importing XML Villerat Excel Discussion (Misc queries) 0 July 24th 08 01:59 AM
Importing multiline records files into Excel cells michaelp Excel Discussion (Misc queries) 6 November 6th 06 07:07 PM
importing another file format into Excel Leesa Excel Discussion (Misc queries) 1 May 13th 05 03:43 AM
Importing Word Paragraph to Excel - 1 cell, same formating -- I lose the format Chris DeNardis Excel Programming 4 February 23rd 05 04:07 PM


All times are GMT +1. The time now is 11:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"