I have multiple excel file where contains salary sheet data. like that..
EMP1001.xls or EMP1001.xlsx ---- here EMP1001 is a employee no of a employee
| month | basic | da | hra | total |
| jan | 20000 | 15000 | 3000 | 38000 |
| feb | 19800 | 14000 | 2860 | 36660 |
| mar | 23200 | 16000 | 3050 | 42250 |
EMP1002.xls or EMP1002.xlsx
| month | basic | da | hra | total |
| jan | 8000 | 14000 | 2500 | 24500 |
| feb | 9000 | 17000 | 2100 | 28100 |
| mar | 10000 | 19000 | 1800 | 30800 |
I create a database table and extract excel data
| emp_no | month | basic | da | hra | net |
| EMP1001 | jan | 20000 | 15000 | 3000 | 38000 |
| EMP1001 | feb | 19800 | 14000 | 2860 | 36660 |
| EMP1001 | mar | 23200 | 16000 | 3050 | 42250 |
| EMP1002 | jan | 8000 | 14000 | 2500 | 24500 |
| EMP1002 | feb | 9000 | 17000 | 2100 | 28100 |
| EMP1002 | mar | 10000 | 19000 | 1800 | 30800 |
Actually I done all of these process with single file upload.
I want to upload multiple excel file and insert these data into database from excel file.
Please help me.
Leon DPosted Dec 2, 2018, 7:57 PM
Prakash MondalPosted Dec 1, 2018, 11:51 PM
openFileDialog1.InitialDirectory = @"C:\";
openFileDialog1.Title = "Browse Image Files";
openFileDialog1.CheckFileExists = true;
openFileDialog1.CheckPathExists = true;
openFileDialog1.DefaultExt = "txt";
openFileDialog1.Filter = "Excel files (*.xls)|*.xls|Excel files (*.xlsx)|*.xlsx";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
openFileDialog1.ReadOnlyChecked = true;
openFileDialog1.ShowReadOnly = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
DataTable dt = new DataTable();
OleDbConnection conn = new OleDbConnection(connString);
if (conn.State == ConnectionState.Closed)
conn.Open();
OleDbCommand cmd = new OleDbCommand(query, conn);
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
//da.Fill(ds);
da.Fill(dt);
conn.Close();
conn.Dispose();
Jignesh KumarPosted Dec 1, 2018, 8:37 AM