Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hey Guys,
 
i've a serious situation,
 
My Client gives me an excel file for some data.
 
The excel file is exported from Crystal Report of another application that i don't have
 
autorization to edit in it.
 
He wants me to add a page to my website that could upload and insert these data to my website
 
because there might be another Excel files to upload and insert.
 
I've tried alot to find some way to get data in that excel file but i've faced these problems:
 
1- The Columns in the excel file are interacted in some studpid way i don't know it.
 
2- There is a header in the excel file that contains useless data.
 
So i wish if any one have an ideas to do that.
 
I've prepared a template file to the Excel file (data starts from row no. 15)
Col14	Col13	Col12	Col11	Col10			Col9	Col8	Col7		Col6		Col5	Col4	Col3		Col2	Col1
98	 	 	 				0	0	0		0			655	 		Name 1	123
987	 	 	 				0	0	0		0		asd	654	 		Name 2	234
987987	 	 	 				0	0	0		0		zxc	897	الهند		Name 3	45
999	 	 	 				0	0	0		0		aqwe	888	مصر		Name 4	645
8741	 	 	 				0	0	0		0		vdfg	6555	الاردن		Name 5	76
 

HERE is the Link on Mediafire
 
Thanks in Advance
Posted 29-Apr-13 0:57am
AmrDeif657
Edited 29-Apr-13 1:31am
Maciej Los161.2K
v3
Comments
Maciej Los at 29-Apr-13 6:34am
   
It does not work like that! No one want to download any file.
Please, shrotly describe data structure and provide useful information about your issue...
 
What have you done so far? Where are you stuck?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try below code...
In below code, u will read Excel data and can use insert Datatable or u can use as show in below....
 
Select the ACCESSExcel Table INTO an Excel Spreadsheet
            try
            {
                //SELECT INTO command                
                string cnStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + AccfilePath +
                   ";Persist Security Info=False";
 
                ConnOpen(cnStr);
 
                using (connectionToDatabase)
                {
                    //Give the Export Table (destination) a Name
                    //baseTblName = dt.TableName;

                    //Generate the SQL string to SELECT * INTO the NEW table in destination
                    
string selectcmd = "SELECT * " +
               "FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0'," +
               "'Excel 12.0;Database=" + EXCELfilpath + ";IMEX=1'," +
               "'SELECT * FROM ["+sheetName+"$]')";
 

 
                    using (OleDbCommand createCmd = new OleDbCommand(selectcmd, connectionToDatabase))
                    {
                        createCmd.ExecuteNonQuery();
                    }
 
                    ConnClose();
                }
            }
  Permalink  
v2
Comments
AmrDeif at 30-Apr-13 2:58am
   
Thanks Kushal.patil121 for your reply
but i've solved it my self
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

thanks Guys i've solved it my self
 
i've convinced my client to put the data in some kind of a template file
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 ridoy 440
1 Maciej Los 414
2 DamithSL 150
3 Suvendu Shekhar Giri 150
4 Richard MacCutchan 144
0 OriginalGriff 8,033
1 DamithSL 6,179
2 Sergey Alexandrovich Kryukov 5,538
3 Maciej Los 5,508
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 30 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100