You can use ExcelDataReader to read existing Excel
file:
using (var stream = File.Open("C:\\temp\\input.xlsx", FileMode.Open, FileAccess.Read))
{
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
while (reader.Read())
{
for (var i = 0; i < reader.FieldCount; i++)
{
var value = reader.GetValue(i)?.ToString();
}
}
}
}
After you collected all data needed you can try my SwiftExcel library to export it to the new Excel
file:
using (var ew = new ExcelWriter("C:\\temp\\output.xlsx"))
{
for (var i = 1; i < 10; i++)
{
ew.Write("your_data", i, 1);
}
}
Nuget commands to install both libraries:
Install-Package ExcelDataReader
Install-Package SwiftExcel