• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 894
  • Last Modified:

VS 2003 C# -- writing to Excel

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
g_johnson
Asked:
g_johnson
1 Solution
 
GarrettyCommented:
In VB you would use:

Columns.AutoFit
0
 
g_johnsonAuthor Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now