When i import an XLSX file and save it, Excell table are gone.
I use this table name in some formules.
I want insert some dynamic header information and some rows to the table.
I cant find any documentation which other things will be lost when i export the file.
private void OpenFile()
{
string fileName = @"Template.xlsx";
_xlsxProvider = new XlsxFormatProvider();
using (Stream stream = File.OpenRead(fileName))
{
try
{
_workbook = _xlsxProvider.Import(stream);
_worksheet = _workbook.ActiveWorksheet;
_workbook.History.IsEnabled = false;
}
catch (Exception)
{
Console.WriteLine("Could not open file.");
}
}
}
public Stream GetOutputStream()
{
Stream stream = new MemoryStream();
_xlsxProvider.Export(_workbook, stream);
stream.Position = 0;
return stream;
}
var stream = _excelService.GetOutputStream();
//write stream to fole
using (var fileStream = File.Create("Output.xlsx"))
{
await stream.CopyToAsync(fileStream);
}