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

How to read Excel in C#?

Hi,

I read some articles about handle Excel in C#, they all need import Excel
library. That means you need install Excel on that machine. I am wonderring
SQL 2000 handle Excel, you can import Excel file in SQL 2000 which doesn't
require you install Excel. How could I do the same thing with C#?

thanks!
Oct 9 '05 #1
3 34135
First thing you will always need reference of "Excel 10 Object Library
" to do excel manipulation ( until you want to write your own excel
parser ). If you are not sure that your clients will have excel on
there machine send it to server ( if you are using aspx you always do
that) and parse it on the server. Now you will only need to install
excel in one place thats on the server.

-------
Regards ,
C#, VB.NET , SQL SERVER , UML , DESIGN Patterns Interview question book
http://www.geocities.com/dotnetinterviews/
My Interview Blog
http://spaces.msn.com/members/dotnetinterviews/

Oct 9 '05 #2
On 9 Oct 2005 01:05:20 -0700, sh**********@yahoo.com wrote:
First thing you will always need reference of "Excel 10 Object Library
" to do excel manipulation ( until you want to write your own excel
parser ). If you are not sure that your clients will have excel on
there machine send it to server ( if you are using aspx you always do
that) and parse it on the server. Now you will only need to install
excel in one place thats on the server.


Not a really good idea apparently:
http://support.microsoft.com/default...b;en-us;257757

If you need to parse Excel files (and any MS Office files) without having
Office installed, you can use a third party component such as the Aspose
ones http://www.aspose.com/default.aspx
Oct 9 '05 #3
On Sat, 8 Oct 2005 21:43:25 -0700, "davidw" <da****@affinisys.com> wrote:

¤ Hi,
¤
¤ I read some articles about handle Excel in C#, they all need import Excel
¤ library. That means you need install Excel on that machine. I am wonderring
¤ SQL 2000 handle Excel, you can import Excel file in SQL 2000 which doesn't
¤ require you install Excel. How could I do the same thing with C#?

You don't need the Excel object library, you can use ADO.NET and SQL:

Function ExportExcelToSQLServer() As Boolean

Dim ExcelConnection As New
System.Data.OleDb.OleDbConnection("Provider=Micros oft.Jet.OLEDB.4.0;" & _
"Data Source=" & "E:\My
Documents\Book5.xls" & ";" & _
"Extended Properties=""Excel
8.0;HDR=No""")

ExcelConnection.Open()

'Existing table
Dim ExcelCommand As New System.Data.OleDb.OleDbCommand("INSERT INTO [ODBC;Driver={SQL
Server};Server=(local);Database=Northwind;Trusted_ Connection=yes].[Orders2] SELECT * FROM
[Orders$];", ExcelConnection)
'New table
'Dim ExcelCommand As New System.Data.OleDb.OleDbCommand("SELECT INTO [ODBC;Driver={SQL
Server};Server=(local);Database=Northwind;Trusted_ Connection=yes].[Orders2] FROM [Orders$];",
ExcelConnection)

ExcelCommand.ExecuteNonQuery()
ExcelConnection.Close()

End Function
Paul
~~~~
Microsoft MVP (Visual Basic)
Oct 11 '05 #4

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

Similar topics

2
by: newtophp2000 | last post by:
I created a system DSN for an Excel file and I have been using it for a while. I can read from it as well as update it. (The Excel file includes weekly updates to some records.) Then I tried...
10
by: QQ | last post by:
I am trying to read data from Excel files I use the following codes, however, it didn't work Can anyone tell me what the format excel files have, what I should do to read it from C? Thanks a...
1
by: Roger Twomey | last post by:
I have a form that allows a user to upload a microsoft Excel Spreadsheet. (I am testing with one created in Excel 2000) The spreadsheet is uploaded correctly. It is then supposed to be read...
2
by: Reza Solouki | last post by:
Hello, I never had to do anything with office tools programmatically till now(I guess there is first time for everything), so this might be a very silly and simple question for some of you. Any...
4
by: Seok Bee | last post by:
Dear Experts, I have created a script to extract the Event Logs from the system into an excel sheet. The logs are separated into 2 worksheets (Application Log and System Log). After this excel...
4
by: Marco Aschwanden | last post by:
Hi I would like to 1. import an existing Excel-sheet (a template) 2. and add some data to it 3. and save it under a different name afterwards. To me it seems, that pyExcelerator does not...
3
by: sajithkahawatta | last post by:
is there any one used aspose.excel i used automation to read a exel doc .but we have to install ms excel to do that so i suppose to use aspose.excel can any one give me the 'Aspose.Excel.dll' and...
6
by: jagguy | last post by:
Hi, i cant read in data from excel 97 using vb.net 2003. I get an exception error . all i want to do is read in values from excel initially. I want to just test it using msgbox. Dim XL...
3
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
3
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.