473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

C# Format columns in excel

Hi all...i'm having a problem in formatting columns in excel. For example i have column Name, Birth Date and Salary and i want to format it to string, date and numeric respectively. When i format the columns using the codes below, all columns format become numeric. Any advise @ reference i can refer to?

objField = (ADODB.Field)objFields.Current;

Expand|Select|Wrap|Line Numbers
  1.  for (int n = 0; n < nFields; n++)
  2.                                 {
  3.                                     switch (objField.Type.ToString())
  4.                                     {
  5.                                         case "adVarWChar":
  6.                                         case "advarwchar":
  7.                                             {
  8.                                                break;
  9.                                             }
  10.                                         case "adDBTimeStamp":
  11.                                         case "addbtimestamp":
  12.                                             {
  13.                                                 ((Range)sheet1.Cells[1, n + 1]).EntireColumn.NumberFormat = "dd-mmm-yy";
  14.                                                 break;
  15.                                             }
  16.                                         case "adNumeric":
  17.                                         case "adnumeric":
  18.                                             {
  19.                                                 ((Range)sheet1.Cells[1, n + 1]).EntireColumn.NumberFormat = "0.00";
  20.                                                 break;
  21.                                             }
  22.                                     }
  23.                                 }
Aug 15 '08 #1
2 7115
r035198x
13,262 8TB
You are not looping through all the fields. You are running the loop for only the current field.
Aug 15 '08 #2
You are not looping through all the fields. You are running the loop for only the current field.
Yes looping is the problem :) Thanks
Aug 16 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: thomasp | last post by:
I have a datagridview in vb.net 2005 that pulls its data from an Access Database. The database has a time column. When you view the data in Access it shows only a time in 24hour format. When the...
2
by: Scott M. Lyon | last post by:
I currently am working on a VB.NET application that imports data from an Excel spreadsheet that the customer filled in. I used the following code to use ODBC to read the data from the...
1
by: desi.american | last post by:
I have a dynamically generates ASPX page with tables and data. Depending on user selection, the same page can be viewed as a simple web page (rendered in HTML) or as an excel spreadsheet. If the...
18
by: gonzlobo | last post by:
No, I don't want to destroy them (funny how the word 'decimate' has changed definition over the years) :). We have a data acquisition program that saves its output to Excel's ..xls format....
3
neo008
by: neo008 | last post by:
Hi all, What is the best way to format cells of an Excel sheet? I have read somewhere "object.range.property" method. but it's tedious if we do it cell by cell. Moreover most of the properties...
1
by: Neo007 | last post by:
**File Conversion from CSV format to Excel(.xsl) C# Detailed Requirement is : Requirements for File Conversion Application: 1.My Application must be command-line it should indicate success...
7
by: Kosmos | last post by:
Howdy...haven't used Access for a while, but now I'm getting back into it and can't seem to figure out how I can import data from an excel table that outputs the date in the formate of MMDDYYYY. I...
4
juve11
by: juve11 | last post by:
hello, i made alot of changes to an excel sheet from visual basic like bordering,setting landscape,margins... but there is a thing a didnt managed to change : the cell format. i have two columns...
3
by: Bface | last post by:
Hi all, Hope everyone had a good holiday. I am having a difficult time changing the date format of a field from Excel. I have never had this problem before. I link the excel spreadsheet to my DB,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.