Set Home| Set Favorite|

WPS Office Forum

 Forgot password?
 Register
Search
View: 890|Reply: 0

Read KSO spreadsheet .et file from C#.net in a windows application

[ Promote this link! ]
Post time: 2016-08-18 03:28:59
| Show all posts |!read_mode!
Hi experts,

My requirement is to read all records from a .et file and then work with the data in my windows application using c#.net
Currently it is working smooth if using MS excel file but now since my requirement has changed, I need to do the same with .et file only.
Please note: the machine do not have MS office installed in it.

Below is the code which is working fine for MS excel file. Here I am reading the excel and putting all the data in a data set. I need something similar for .et files.
Kindly help. have been stuck for 2 days here.

string strFilePath = txtFile.Text;
            string strConnection = "";
            String strSQL = "SELECT F1 As [Column1],F2 As [Column2], F3 As [Column3], F4 As [Column4] FROM [Sheet1$];";
            
            strConnection = @"rovider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strFilePath + ";Excel 8.0; HDR=NO; IMEX=1ersist Security Info=False";
            OleDbConnection conExcel = new OleDbConnection(strConnection);

            try
            {
                conExcel.Open();

                //Create a data adapter and fill the data command to it
                OleDbCommand cmdExcel = new OleDbCommand(strSQL, conExcel);
                OleDbDataAdapter dtadptExcel = new OleDbDataAdapter();
                dtadptExcel.SelectCommand = cmdExcel;

                //Create a data set and populate using data adapter
                DataSet dsExcelData = new DataSet();
                dtadptExcel.Fill(dsExcelData);
                return dsExcelData;
            }
            catch (Exception ex)
            {
                throw new Exception("Error Occured!",ex);
            }

Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Dark room|Mobile|Archiver|WPS Office   

2019-07-20 18:43 GMT+8 , !processed_in! 0.077333 !seconds!, 16 !queries! .

Powered by Discuz! X3.2

Release 20151208, © 2001-2019 Comsenz Inc.

MultiLingual version, Rev. 469, © 2009-2019 codersclub.org

!fastreply! To Top !return_list!