Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

VS 2003 C# -- writing to Excel

Posted on 2007-08-06
2
Medium Priority
?
891 Views
Last Modified: 2008-01-09
From C# (VS 2003) I am writing to an Excel Spreadsheet using techniques like this:

range.get_Offset(l,0).set_Value(Missing.Value,"Account Number");
range.get_Offset(l,1).set_Value(Missing.Value,"Management Group");
range.get_Offset(l,2).set_Value(Missing.Value,"Customer Type");
range.get_Offset(l,3).set_Value(Missing.Value,"Customer Date of Birth");
range.get_Offset(l,4).set_Value(Missing.Value,"Customer Name");

and

range.get_Offset(l,3).EntireColumn.NumberFormat = "MM/DD/YYYY";

The spreadsheet ends up with 63 columns.

Before saving, I would like to adjust the column width for each column to match the size of the data written to it.  If possible I would like to emulate the Excel process whereby you select all columns and double-click on a border to automatically adjust them.  If that's not possible, I would need to adjust each column manually.

How do I accomplish this?
0
Comment
Question by:g_johnson
2 Comments
 
LVL 4

Accepted Solution

by:
Garretty earned 2000 total points
ID: 19642111
In VB you would use:

Columns.AutoFit
0
 
LVL 4

Author Comment

by:g_johnson
ID: 19645082
thanks
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question