Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
144030 | Apr 15,2019 02:09 PM UTC | Apr 17,2019 03:41 PM UTC | WinForms | 3 |
![]() |
Tags: XlsIO |
FileStream inputStream = new FileStream("../../Data/Test.xlsx", FileMode.Open, FileAccess.ReadWrite);
ExcelEngine engine = new ExcelEngine();
IApplication app = engine.Excel;
IWorkbook book = app.Workbooks.Open(inputStream);
book.SaveAs("../../Output/Resave.xlsx");
book.Close();
engine.Dispose();
inputStream.Close(); |
string clean1 = "SELECT * FROM [SOURCE$] WHERE [Region] = '" + regionBox.Items[r].ToString() + "'";
try
{
odcSOURCE.Open();
}
catch { }
OleDbDataAdapter dAdapter1 = new OleDbDataAdapter();
OleDbCommand cmd1 = new OleDbCommand(clean1, odcSOURCE);
cmd1.Parameters.Add("?", OleDbType.Integer, 5).Value = 1234;
cmd1.Parameters.Add("?", OleDbType.BSTR, 5).Value = "asdf";
dAdapter1.SelectCommand = cmd1;
System.Data.DataTable dt1 = new System.Data.DataTable();
dAdapter1.Fill(dt1);
odc.Close();
odc.Dispose();
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open(exeDir + "\\Templates\\" + comboBox3.Text + "\\" + comboBox3.Text + " -Data.xlsx");
IWorksheet dataTab = workbook.Worksheets["DATA"];
try
{
dataTab.UsedRange.Clear();
}
catch { }
dataTab.ImportDataTable(dt1, true, 1, 1);
workbook.SaveAs(exeDir + "\\Templates\\" + comboBox3.Text + "\\" + comboBox3.Text + " -Data.xlsx");
workbook.Close(false);
excelEngine.Dispose();
dt1.Dispose();
GC.Collect();
GC.Collect();
The loop continues on to do various things.
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.