How can we Validate Column names of Excel sheet with Table values using OLEDB
I want to validate column names of uploaded excel sheet with table definition.
Here i get table definition from database and also i get the column names from excel sheet using OLEDB.
i want to validate where all the column from the table is available in excel columns. Here i get both column names (that is from excel and table (DB)).
Here is the code i tried
//for validating column names
public bool ValidateColumnNames(string filename,DataExchangeDefinition dataExchangeDefinition)
{
string extension = Path.GetExtension(filename);
string connstring = string.Empty;
try
{
switch (extension)
{
case ".xls":
connstring = string.Format(ConfigurationManager.ConnectionStrings["Excel03ConString"].ConnectionString, filename);
break;
case ".xlsx":
connstring = string.Format(ConfigurationManager.ConnectionStrings["Excel07+ConString"].ConnectionString, filename);
break;
}
using (OleDbConnection connExcel = new OleDbConnection(connstring))
{
using (OleDbCommand cmd = new OleDbCommand())
{
cmd.Connection = connExcel;
connExcel.Open();
var dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
connExcel.Close();
string firstSheet = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();
cmd.CommandText = "SELECT top 1 * FROM [" + firstSheet + "]";
using (OleDbDataAdapter da = new OleDbDataAdapter(cmd))
{
DataTable HeaderColumns = new DataTable();
da.SelectCommand = cmd;
da.Fill(HeaderColumns);
foreach (DataColumn column in HeaderColumns.Columns)
{
//Here i want to validate the column names
dataExchangeDefinition.FieldName = column.Caption.ToString();
}
}
}
}
}
catch (Exception ex)
{
throw ex;
}
return true;
}
c# excel asp.net-mvc oledb
add a comment |
I want to validate column names of uploaded excel sheet with table definition.
Here i get table definition from database and also i get the column names from excel sheet using OLEDB.
i want to validate where all the column from the table is available in excel columns. Here i get both column names (that is from excel and table (DB)).
Here is the code i tried
//for validating column names
public bool ValidateColumnNames(string filename,DataExchangeDefinition dataExchangeDefinition)
{
string extension = Path.GetExtension(filename);
string connstring = string.Empty;
try
{
switch (extension)
{
case ".xls":
connstring = string.Format(ConfigurationManager.ConnectionStrings["Excel03ConString"].ConnectionString, filename);
break;
case ".xlsx":
connstring = string.Format(ConfigurationManager.ConnectionStrings["Excel07+ConString"].ConnectionString, filename);
break;
}
using (OleDbConnection connExcel = new OleDbConnection(connstring))
{
using (OleDbCommand cmd = new OleDbCommand())
{
cmd.Connection = connExcel;
connExcel.Open();
var dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
connExcel.Close();
string firstSheet = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();
cmd.CommandText = "SELECT top 1 * FROM [" + firstSheet + "]";
using (OleDbDataAdapter da = new OleDbDataAdapter(cmd))
{
DataTable HeaderColumns = new DataTable();
da.SelectCommand = cmd;
da.Fill(HeaderColumns);
foreach (DataColumn column in HeaderColumns.Columns)
{
//Here i want to validate the column names
dataExchangeDefinition.FieldName = column.Caption.ToString();
}
}
}
}
}
catch (Exception ex)
{
throw ex;
}
return true;
}
c# excel asp.net-mvc oledb
I guess you can avoid usingOleDbConnection
by using EPPlus library (i.e. Office is not required to be installed). If you know the range of your headers, this library can easily fetch them.
– JohnyL
Jan 1 at 18:30
Side note:throw ex
will give you trouble later because it eliminates the original stacktrace. The stacktrace will indicate that the exception originates on thethrow ex
line, so you won't know where it actually happened. If all you're doing is catching and rethrowing then it's better to just leave out thetry/catch
entirely.
– Scott Hannen
Jan 1 at 18:59
add a comment |
I want to validate column names of uploaded excel sheet with table definition.
Here i get table definition from database and also i get the column names from excel sheet using OLEDB.
i want to validate where all the column from the table is available in excel columns. Here i get both column names (that is from excel and table (DB)).
Here is the code i tried
//for validating column names
public bool ValidateColumnNames(string filename,DataExchangeDefinition dataExchangeDefinition)
{
string extension = Path.GetExtension(filename);
string connstring = string.Empty;
try
{
switch (extension)
{
case ".xls":
connstring = string.Format(ConfigurationManager.ConnectionStrings["Excel03ConString"].ConnectionString, filename);
break;
case ".xlsx":
connstring = string.Format(ConfigurationManager.ConnectionStrings["Excel07+ConString"].ConnectionString, filename);
break;
}
using (OleDbConnection connExcel = new OleDbConnection(connstring))
{
using (OleDbCommand cmd = new OleDbCommand())
{
cmd.Connection = connExcel;
connExcel.Open();
var dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
connExcel.Close();
string firstSheet = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();
cmd.CommandText = "SELECT top 1 * FROM [" + firstSheet + "]";
using (OleDbDataAdapter da = new OleDbDataAdapter(cmd))
{
DataTable HeaderColumns = new DataTable();
da.SelectCommand = cmd;
da.Fill(HeaderColumns);
foreach (DataColumn column in HeaderColumns.Columns)
{
//Here i want to validate the column names
dataExchangeDefinition.FieldName = column.Caption.ToString();
}
}
}
}
}
catch (Exception ex)
{
throw ex;
}
return true;
}
c# excel asp.net-mvc oledb
I want to validate column names of uploaded excel sheet with table definition.
Here i get table definition from database and also i get the column names from excel sheet using OLEDB.
i want to validate where all the column from the table is available in excel columns. Here i get both column names (that is from excel and table (DB)).
Here is the code i tried
//for validating column names
public bool ValidateColumnNames(string filename,DataExchangeDefinition dataExchangeDefinition)
{
string extension = Path.GetExtension(filename);
string connstring = string.Empty;
try
{
switch (extension)
{
case ".xls":
connstring = string.Format(ConfigurationManager.ConnectionStrings["Excel03ConString"].ConnectionString, filename);
break;
case ".xlsx":
connstring = string.Format(ConfigurationManager.ConnectionStrings["Excel07+ConString"].ConnectionString, filename);
break;
}
using (OleDbConnection connExcel = new OleDbConnection(connstring))
{
using (OleDbCommand cmd = new OleDbCommand())
{
cmd.Connection = connExcel;
connExcel.Open();
var dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
connExcel.Close();
string firstSheet = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();
cmd.CommandText = "SELECT top 1 * FROM [" + firstSheet + "]";
using (OleDbDataAdapter da = new OleDbDataAdapter(cmd))
{
DataTable HeaderColumns = new DataTable();
da.SelectCommand = cmd;
da.Fill(HeaderColumns);
foreach (DataColumn column in HeaderColumns.Columns)
{
//Here i want to validate the column names
dataExchangeDefinition.FieldName = column.Caption.ToString();
}
}
}
}
}
catch (Exception ex)
{
throw ex;
}
return true;
}
c# excel asp.net-mvc oledb
c# excel asp.net-mvc oledb
edited Jan 2 at 4:00
dhanil dinesan
asked Jan 1 at 12:03
dhanil dinesandhanil dinesan
709
709
I guess you can avoid usingOleDbConnection
by using EPPlus library (i.e. Office is not required to be installed). If you know the range of your headers, this library can easily fetch them.
– JohnyL
Jan 1 at 18:30
Side note:throw ex
will give you trouble later because it eliminates the original stacktrace. The stacktrace will indicate that the exception originates on thethrow ex
line, so you won't know where it actually happened. If all you're doing is catching and rethrowing then it's better to just leave out thetry/catch
entirely.
– Scott Hannen
Jan 1 at 18:59
add a comment |
I guess you can avoid usingOleDbConnection
by using EPPlus library (i.e. Office is not required to be installed). If you know the range of your headers, this library can easily fetch them.
– JohnyL
Jan 1 at 18:30
Side note:throw ex
will give you trouble later because it eliminates the original stacktrace. The stacktrace will indicate that the exception originates on thethrow ex
line, so you won't know where it actually happened. If all you're doing is catching and rethrowing then it's better to just leave out thetry/catch
entirely.
– Scott Hannen
Jan 1 at 18:59
I guess you can avoid using
OleDbConnection
by using EPPlus library (i.e. Office is not required to be installed). If you know the range of your headers, this library can easily fetch them.– JohnyL
Jan 1 at 18:30
I guess you can avoid using
OleDbConnection
by using EPPlus library (i.e. Office is not required to be installed). If you know the range of your headers, this library can easily fetch them.– JohnyL
Jan 1 at 18:30
Side note:
throw ex
will give you trouble later because it eliminates the original stacktrace. The stacktrace will indicate that the exception originates on the throw ex
line, so you won't know where it actually happened. If all you're doing is catching and rethrowing then it's better to just leave out the try/catch
entirely.– Scott Hannen
Jan 1 at 18:59
Side note:
throw ex
will give you trouble later because it eliminates the original stacktrace. The stacktrace will indicate that the exception originates on the throw ex
line, so you won't know where it actually happened. If all you're doing is catching and rethrowing then it's better to just leave out the try/catch
entirely.– Scott Hannen
Jan 1 at 18:59
add a comment |
1 Answer
1
active
oldest
votes
Here is the answer it works fine for me
//for validating column names
public List<DataExchangeDefinition> ValidateColumnNames(string filename, List<DataExchangeDefinition> dataExchangeDefinitionList)
{
DataExchangeDefinition dt = new DataExchangeDefinition();
//List<DataExchangeDefinition> dataexchangedefinitionList = new List<DataExchangeDefinition>();
string extension = Path.GetExtension(filename);
string connstring = string.Empty;
try
{
switch (extension)
{
case ".xls":
connstring = string.Format(ConfigurationManager.ConnectionStrings["Excel03ConString"].ConnectionString, filename);
break;
case ".xlsx":
connstring = string.Format(ConfigurationManager.ConnectionStrings["Excel07+ConString"].ConnectionString, filename);
break;
}
using (OleDbConnection connExcel = new OleDbConnection(connstring))
{
using (OleDbCommand cmd = new OleDbCommand())
{
cmd.Connection = connExcel;
connExcel.Open();
var dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); //To get the sheet name
connExcel.Close();
string firstSheet = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();
cmd.CommandText = "SELECT top 1 * FROM [" + firstSheet + "]";
using (OleDbDataAdapter da = new OleDbDataAdapter(cmd))
{
DataTable HeaderColumns = new DataTable();
da.SelectCommand = cmd;
da.Fill(HeaderColumns);
//List<DataColumn> excelColumn = new List<DataColumn>();
//var excelColumn = new List<DataColumn>();
//foreach (DataColumn column in HeaderColumns.Columns)
//{
// excelColumn.Add(column);
//}
foreach (DataExchangeDefinition data in dataExchangeDefinitionList)
//for(int i=0;i<dataExchangeDefinitionList.Count;i++)
{
dt.IsColumnValid = false;
//var result = from excelColumn in HeaderColumns;
foreach (DataColumn column in HeaderColumns.Columns)
{
if (data.FieldCaption == column.Caption)
{
data.IsColumnValid = true;
break;
}
}
}
return dataExchangeDefinitionList;
}
}
}
}
catch (Exception ex)
{
throw ex;
}
//return isColumnValid;
}
}
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53995264%2fhow-can-we-validate-column-names-of-excel-sheet-with-table-values-using-oledb%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here is the answer it works fine for me
//for validating column names
public List<DataExchangeDefinition> ValidateColumnNames(string filename, List<DataExchangeDefinition> dataExchangeDefinitionList)
{
DataExchangeDefinition dt = new DataExchangeDefinition();
//List<DataExchangeDefinition> dataexchangedefinitionList = new List<DataExchangeDefinition>();
string extension = Path.GetExtension(filename);
string connstring = string.Empty;
try
{
switch (extension)
{
case ".xls":
connstring = string.Format(ConfigurationManager.ConnectionStrings["Excel03ConString"].ConnectionString, filename);
break;
case ".xlsx":
connstring = string.Format(ConfigurationManager.ConnectionStrings["Excel07+ConString"].ConnectionString, filename);
break;
}
using (OleDbConnection connExcel = new OleDbConnection(connstring))
{
using (OleDbCommand cmd = new OleDbCommand())
{
cmd.Connection = connExcel;
connExcel.Open();
var dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); //To get the sheet name
connExcel.Close();
string firstSheet = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();
cmd.CommandText = "SELECT top 1 * FROM [" + firstSheet + "]";
using (OleDbDataAdapter da = new OleDbDataAdapter(cmd))
{
DataTable HeaderColumns = new DataTable();
da.SelectCommand = cmd;
da.Fill(HeaderColumns);
//List<DataColumn> excelColumn = new List<DataColumn>();
//var excelColumn = new List<DataColumn>();
//foreach (DataColumn column in HeaderColumns.Columns)
//{
// excelColumn.Add(column);
//}
foreach (DataExchangeDefinition data in dataExchangeDefinitionList)
//for(int i=0;i<dataExchangeDefinitionList.Count;i++)
{
dt.IsColumnValid = false;
//var result = from excelColumn in HeaderColumns;
foreach (DataColumn column in HeaderColumns.Columns)
{
if (data.FieldCaption == column.Caption)
{
data.IsColumnValid = true;
break;
}
}
}
return dataExchangeDefinitionList;
}
}
}
}
catch (Exception ex)
{
throw ex;
}
//return isColumnValid;
}
}
}
add a comment |
Here is the answer it works fine for me
//for validating column names
public List<DataExchangeDefinition> ValidateColumnNames(string filename, List<DataExchangeDefinition> dataExchangeDefinitionList)
{
DataExchangeDefinition dt = new DataExchangeDefinition();
//List<DataExchangeDefinition> dataexchangedefinitionList = new List<DataExchangeDefinition>();
string extension = Path.GetExtension(filename);
string connstring = string.Empty;
try
{
switch (extension)
{
case ".xls":
connstring = string.Format(ConfigurationManager.ConnectionStrings["Excel03ConString"].ConnectionString, filename);
break;
case ".xlsx":
connstring = string.Format(ConfigurationManager.ConnectionStrings["Excel07+ConString"].ConnectionString, filename);
break;
}
using (OleDbConnection connExcel = new OleDbConnection(connstring))
{
using (OleDbCommand cmd = new OleDbCommand())
{
cmd.Connection = connExcel;
connExcel.Open();
var dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); //To get the sheet name
connExcel.Close();
string firstSheet = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();
cmd.CommandText = "SELECT top 1 * FROM [" + firstSheet + "]";
using (OleDbDataAdapter da = new OleDbDataAdapter(cmd))
{
DataTable HeaderColumns = new DataTable();
da.SelectCommand = cmd;
da.Fill(HeaderColumns);
//List<DataColumn> excelColumn = new List<DataColumn>();
//var excelColumn = new List<DataColumn>();
//foreach (DataColumn column in HeaderColumns.Columns)
//{
// excelColumn.Add(column);
//}
foreach (DataExchangeDefinition data in dataExchangeDefinitionList)
//for(int i=0;i<dataExchangeDefinitionList.Count;i++)
{
dt.IsColumnValid = false;
//var result = from excelColumn in HeaderColumns;
foreach (DataColumn column in HeaderColumns.Columns)
{
if (data.FieldCaption == column.Caption)
{
data.IsColumnValid = true;
break;
}
}
}
return dataExchangeDefinitionList;
}
}
}
}
catch (Exception ex)
{
throw ex;
}
//return isColumnValid;
}
}
}
add a comment |
Here is the answer it works fine for me
//for validating column names
public List<DataExchangeDefinition> ValidateColumnNames(string filename, List<DataExchangeDefinition> dataExchangeDefinitionList)
{
DataExchangeDefinition dt = new DataExchangeDefinition();
//List<DataExchangeDefinition> dataexchangedefinitionList = new List<DataExchangeDefinition>();
string extension = Path.GetExtension(filename);
string connstring = string.Empty;
try
{
switch (extension)
{
case ".xls":
connstring = string.Format(ConfigurationManager.ConnectionStrings["Excel03ConString"].ConnectionString, filename);
break;
case ".xlsx":
connstring = string.Format(ConfigurationManager.ConnectionStrings["Excel07+ConString"].ConnectionString, filename);
break;
}
using (OleDbConnection connExcel = new OleDbConnection(connstring))
{
using (OleDbCommand cmd = new OleDbCommand())
{
cmd.Connection = connExcel;
connExcel.Open();
var dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); //To get the sheet name
connExcel.Close();
string firstSheet = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();
cmd.CommandText = "SELECT top 1 * FROM [" + firstSheet + "]";
using (OleDbDataAdapter da = new OleDbDataAdapter(cmd))
{
DataTable HeaderColumns = new DataTable();
da.SelectCommand = cmd;
da.Fill(HeaderColumns);
//List<DataColumn> excelColumn = new List<DataColumn>();
//var excelColumn = new List<DataColumn>();
//foreach (DataColumn column in HeaderColumns.Columns)
//{
// excelColumn.Add(column);
//}
foreach (DataExchangeDefinition data in dataExchangeDefinitionList)
//for(int i=0;i<dataExchangeDefinitionList.Count;i++)
{
dt.IsColumnValid = false;
//var result = from excelColumn in HeaderColumns;
foreach (DataColumn column in HeaderColumns.Columns)
{
if (data.FieldCaption == column.Caption)
{
data.IsColumnValid = true;
break;
}
}
}
return dataExchangeDefinitionList;
}
}
}
}
catch (Exception ex)
{
throw ex;
}
//return isColumnValid;
}
}
}
Here is the answer it works fine for me
//for validating column names
public List<DataExchangeDefinition> ValidateColumnNames(string filename, List<DataExchangeDefinition> dataExchangeDefinitionList)
{
DataExchangeDefinition dt = new DataExchangeDefinition();
//List<DataExchangeDefinition> dataexchangedefinitionList = new List<DataExchangeDefinition>();
string extension = Path.GetExtension(filename);
string connstring = string.Empty;
try
{
switch (extension)
{
case ".xls":
connstring = string.Format(ConfigurationManager.ConnectionStrings["Excel03ConString"].ConnectionString, filename);
break;
case ".xlsx":
connstring = string.Format(ConfigurationManager.ConnectionStrings["Excel07+ConString"].ConnectionString, filename);
break;
}
using (OleDbConnection connExcel = new OleDbConnection(connstring))
{
using (OleDbCommand cmd = new OleDbCommand())
{
cmd.Connection = connExcel;
connExcel.Open();
var dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); //To get the sheet name
connExcel.Close();
string firstSheet = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();
cmd.CommandText = "SELECT top 1 * FROM [" + firstSheet + "]";
using (OleDbDataAdapter da = new OleDbDataAdapter(cmd))
{
DataTable HeaderColumns = new DataTable();
da.SelectCommand = cmd;
da.Fill(HeaderColumns);
//List<DataColumn> excelColumn = new List<DataColumn>();
//var excelColumn = new List<DataColumn>();
//foreach (DataColumn column in HeaderColumns.Columns)
//{
// excelColumn.Add(column);
//}
foreach (DataExchangeDefinition data in dataExchangeDefinitionList)
//for(int i=0;i<dataExchangeDefinitionList.Count;i++)
{
dt.IsColumnValid = false;
//var result = from excelColumn in HeaderColumns;
foreach (DataColumn column in HeaderColumns.Columns)
{
if (data.FieldCaption == column.Caption)
{
data.IsColumnValid = true;
break;
}
}
}
return dataExchangeDefinitionList;
}
}
}
}
catch (Exception ex)
{
throw ex;
}
//return isColumnValid;
}
}
}
answered Jan 7 at 8:48
dhanil dinesandhanil dinesan
709
709
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53995264%2fhow-can-we-validate-column-names-of-excel-sheet-with-table-values-using-oledb%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I guess you can avoid using
OleDbConnection
by using EPPlus library (i.e. Office is not required to be installed). If you know the range of your headers, this library can easily fetch them.– JohnyL
Jan 1 at 18:30
Side note:
throw ex
will give you trouble later because it eliminates the original stacktrace. The stacktrace will indicate that the exception originates on thethrow ex
line, so you won't know where it actually happened. If all you're doing is catching and rethrowing then it's better to just leave out thetry/catch
entirely.– Scott Hannen
Jan 1 at 18:59