ahmed salah

ahmed salah

  • 1.6k
  • 530
  • 123.2k

How to create more sheet then return message box success

Jan 25 2017 10:43 AM
I work in visual studio 2015 using c# windows form
 
I create excel file 2007 using xlsx with more sheets but
 
i need to return messagebox success tell me that file created
 
So that how to return message box success that show after file excel created ?
 
mycode
  1. public void CreateSheetIfNotExistsmemberAR()  
  2.         {  
  3.             using (System.Data.OleDb.OleDbConnection databaseConnection = new System.Data.OleDb.OleDbConnection())  
  4.             {  
  5.   
  6.                 DataTable schemaTable = default(DataTable);  
  7.   
  8.                 var fileName = string.Format("{0}\\Book3105", Directory.GetCurrentDirectory());  
  9.                 var connection = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source={0};Mode=ReadWrite;Extended Properties=Excel 12.0 Xml;", fileName);  
  10.                 
  11.                 databaseConnection.ConnectionString = connection;  
  12.                 databaseConnection.Open();  
  13.   
  14.                 schemaTable = databaseConnection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, new object[] {  
  15.             null,  
  16.             null,  
  17.             "Sheet3$"  
  18.         });  
  19.   
  20.                 if (schemaTable.Rows.Count == 0)  
  21.                 {  
  22.                     string SQLDDLCommand = "CREATE TABLE [Sheet3] (MemberID INTEGER, MemberName NCHAR(255))";  
  23.                     System.Data.OleDb.OleDbCommand excelCommand = new System.Data.OleDb.OleDbCommand(SQLDDLCommand, databaseConnection);  
  24.                     excelCommand.ExecuteNonQuery();  
  25.   
  26.                 }  
  27.   
  28.                 databaseConnection.Close();  
  29.             }  
  30.         }  
 

Answers (1)