473,395 Members | 1,443 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,395 software developers and data experts.

How to create a new Excel document in c#

I would like to create a new blank excel and set some header columns for the
user.

I try this code. It's work with Excel 2003 English but a got a error line 2
with all other version. (Excel 2003 french, Excel 2000, etc.)
---
Dim oExcel As New Microsoft.Office.Interop.Excel.Application
Dim oBook As Microsoft.Office.Interop.Excel.Workbook

Dim IsNewBook As Boolean = False
If File.Exists(FileName) Then
oBook = oExcel.Workbooks.Open(FileName)
Else
IsNewBook = True
oBook = CType(oExcel.Workbooks.Add(),
Microsoft.Office.Interop.Excel.Workbook)
End If

If oBook Is Nothing Then
Return False
End If

Dim oCell As Microsoft.Office.Interop.Excel.Range
oCell = oExcel.Range("A1")
oCell.Value2 = "LOCATION"
-----------

I use the reference:
Name: Microsoft.Office.Interop.Excel
Description: Microsoft Excel 11.0 Object Library

can someone can help me?

Thanks
Nov 17 '05 #1
1 7416
Frank,

Take a look at this doc:

http://msdn.microsoft.com/library/de..._VSTMultCR.asp

Regards - Octavio

"Franky" <Fr****@discussions.microsoft.com> escribió en el mensaje
news:CE**********************************@microsof t.com...
I would like to create a new blank excel and set some header columns for
the
user.

I try this code. It's work with Excel 2003 English but a got a error line
2
with all other version. (Excel 2003 french, Excel 2000, etc.)
---
Dim oExcel As New Microsoft.Office.Interop.Excel.Application
Dim oBook As Microsoft.Office.Interop.Excel.Workbook

Dim IsNewBook As Boolean = False
If File.Exists(FileName) Then
oBook = oExcel.Workbooks.Open(FileName)
Else
IsNewBook = True
oBook = CType(oExcel.Workbooks.Add(),
Microsoft.Office.Interop.Excel.Workbook)
End If

If oBook Is Nothing Then
Return False
End If

Dim oCell As Microsoft.Office.Interop.Excel.Range
oCell = oExcel.Range("A1")
oCell.Value2 = "LOCATION"
-----------

I use the reference:
Name: Microsoft.Office.Interop.Excel
Description: Microsoft Excel 11.0 Object Library

can someone can help me?

Thanks

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Kerri McDonald | last post by:
We have an application where the user fills out many screens and when they are done, we are supposed to display the text they entered in a word or excel format. That is fairly easily accomplished...
1
by: Brian Johnson | last post by:
I am trying to create multiple (named) worksheets in excel using .Net PIA's. I have successfully created an excel document and set cell values, but have been unable to manipulate which worksheet...
9
by: Paul | last post by:
Hi all Arggghhh........... The problem.....I want the user to be able to create an excel document and name particular cells in the document where they want the data to be placed and then save...
3
by: Paul | last post by:
I have written code to transfer a table to an Excel document. However, I do not know the code to add some "bells and whistles" to the document. Can someone direct me to a reference on the Internet...
0
by: volume | last post by:
Hi all, In an effort to try to impress the boss, I would like to log accounting information to an Excel spreadsheet using C# and .NET. This would be a mockup only, not a real solution - yet! We...
5
by: tmitche | last post by:
I have a C program written in Visual Studio .Net 2002. I have a text file with three fields and 2500 lines that I would like to print to an Excel document. How can this be done and what header...
1
by: Bon | last post by:
Hello all I create a form with three buttons in MS Access 2000. They are Open Excel Template, Save Draft and Save Final. When I click the Open Excel Template button, the Excel template will be...
8
by: K Viltersten | last post by:
I understand that the new versions of MS Word, MS Excel etc. allow for creation of a document using XML tags (the technique or format is called OOXML, i think). I imagine that the idea behind...
4
by: stephen | last post by:
Hi all, I am working with Excel. I read an excel document using ExcelReader and lets say it has 10 columns. I have to read each record and based on a specified column peform some activites and...
6
by: ronparker | last post by:
Hello, This is my first time posting and just my second day using python on mysql, so please be patient with me. I should also say, I am using a linux machine. Using python I was able to make a...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.