read excel file and insert into oracle database

Posted by Basitarif under C# on 9/17/2018 | Points: 10 | Views : 715 | Status : [Member] | Replies : 6
i have excel file with 3 columns and i am trying to insert it oracle database using simple c#forms , is there any step by step document or sample form which can guide me.




Responses

Posted by: Swappy_Gaj on: 9/17/2018 [Member] Starter | Points: 25

Up
1
Down
To Read Excel FIle and Create Datatable and then you can easily insert into database:

https://www.c-sharpcorner.com/UploadFile/6b8651/read-excel-file-in-windows-application-using-C-Sharp/

Basitarif, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lisaw on: 9/20/2018 [Member] Starter | Points: 25

Up
0
Down
You can get free spire.xls.dll from NuGet: https://www.nuget.org/packages/FreeSpire.XLS/

And refer to the below four lines of code to export data from excel to data table:

Workbook workbook = new Workbook();

workbook.LoadFromFile("ImportToExcel.xlsx");

Worksheet sheet = workbook.Worksheets[0];

DataTable datatable = sheet.ExportDataTable();


Then you can easily write the datatable to your database.

Basitarif, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Riotaylor on: 10/16/2018 [Member] Starter | Points: 25

Up
0
Down
I am using the MS Office 365 on my pc having windows 7. I have installed it with the help of https://www.msofficetechnicalsupportnumbers.com/microsoft-office-365-technical-support-phone-number/ I have a dashboard in excel 365 that is connected to 8 spreadsheets. When I send to the mobile device all the sheets are visible except the dashboard, it just shows a blank excel sheet. why this sheet is blank? how can I able to fix this issue??


Basitarif, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vedikaledange on: 12/28/2018 [Member] Starter | Points: 25

Up
0
Down
You may try this code:
private void Button1_Click(System.Object sender, System.EventArgs e)
  {
 
  Excel.Application xlApp = default(Excel.Application);
Excel.Workbook xlWorkBook = default(Excel.Workbook);
  //Excel Application workbooks
 
  Excel.Worksheet xlWorkSheet = default(Excel.Worksheet);
 
  Excel.Range xlRange = default(Excel.Range);
 
  int[] array = new int[646];
 
  int i = 0;
 
  long ra = 0;
 
  string oradb = "Data Source=oracle;User Id=test;Password=123";
 
  xlApp = new Excel.ApplicationClass();
 
  xlApp.Visible = true;
 
  xlWorkBook = xlApp.Workbooks.Open("C:\\excel_file.xls");
 
  xlWorkSheet = xlWorkBook.Worksheets("sheet1");
 
  xlRange = xlWorkSheet.Columns("E");
 
  OracleConnection conn = new OracleConnection(oradb);
 
  conn.Open();
 
  Interaction.MsgBox("open");
 
  OracleCommand cmd = new OracleCommand();
 
  cmd.Connection = conn;
 
  for (i = 2; i <= 647; i++) {
    array[i - 2] = xlRange.Cells(i).value;
    cmd.CommandText = "insert into typlist (baunr) values('" + xlRange.Cells(i).value + "')";
    ra = cmd.ExecuteNonQuery();
}

Interaction.MsgBox("Records Inserted " + ra);

conn.Dispose();

xlWorkBook.Close();

xlApp.Quit();

xlApp = null;

}

DOT NET

Basitarif, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Upsot on: 11/11/2019 [Member] Starter | Points: 25

Up
0
Down
http://gmailloginup.com/gmail-sign-up/

Hi, I do believe this is an excellent blog.

Basitarif, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response