Sat Sep 11, 2021 8:32 pm
Below source is before getting your reply.
The source substitues formula by its value, because SQL requires value not formula.
My question is that your
System.Data.DataTable dataTable = location.ExportDataTable(exportTableOptions);
or
worksheet.InsertDataTable(dataTable, true, 1, 1);
can do the same thing.
My old source
// open output file
using (StreamWriter writer = new StreamWriter(outputFile, false, new UTF8Encoding(false)))
{
// read one line and write it with CR+LF
for (int row = i.Location.Row; row <= i.Location.LastRow; row++)
{
string oneLine = null;
for (int column = i.Location.Column; column <= i.Location.LastColumn; column++)
{
var tmpCell = MyCell(dstCommonSheet, row, column);
string tmpString = null;
if (tmpCell.HasFormula)
{
tmpString = tmpCell.FormulaValue.ToString();
}
else
{
tmpString = tmpCell.Value;
}
oneLine += tmpString + ",";
}
writer.WriteLine(oneLine);
}