'how to overwrite on an existing template in my project, i am using epplus
This is my code, it does not give me an error, but when I download the file, it eliminates the design of my template, how can I solve it?
try
{
var oor_data_response = oDownloadReports.DownloadReports(1);
var row = 3;
string fullFilePath = Path.Combine((System.IO.Directory.GetCurrentDirectory()).Split(new string[] { "/bin/" },
StringSplitOptions.None)[0], "Layouts", "OOR_Report.xlsx");
FileInfo file = new FileInfo(fullFilePath);
using (ExcelPackage package = new ExcelPackage(file))
{
ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
foreach (var items in oor_data_response)
{
worksheet.Cells[row, 1].Value = items.PART;
row++;
}
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
//saveFileDialog1.Title = "Save Excel sheet";
saveFileDialog1.Filter = "Excel files|*.xlsx|All files|*.*";
saveFileDialog1.FileName = "Rpt_OOR_" + DateTime.Now.ToString("dd-MM-yyyy") + ".xlsx";
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
package.SaveAs(file);
MessageBox.Show("Export Successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString(), "NPRC Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
