I am trying to pull down a xlsx document from a s3 bucket and it keeps failing with an error -
{"Zip exception.Unable to read value at the specified position - end of stream was reached."} Syncfusion.Compression.Zip.ZipException but the item it is pulling down is not a zip document
protected void reportfunction_Click(object sender, EventArgs e)
{
{
ExcelEngine excelEngine = new ExcelEngine();
IWorkbook workbook = excelEngine.Excel.Workbooks.Open(getobject());
IWorksheet sheet = workbook.Worksheets[0];
sheet.Range["O1"].Text = "Editing the O1";
//Saves and closes the document instance
workbook.SaveAs(@"C:\Users\" + Environment.UserName + @"\Desktop\Result.xlsx");
workbook.Close();
System.Diagnostics.Process.Start(@"C:\Users\" + Environment.UserName + @"\Desktop\Result.xlsx");
}
}
The code I am using to get the xlsx doc is below. ** Note I was able to use this to successfully pull down a docx file and make changes with SyncFusion. **
private Stream getobject()
{
using (AmazonS3Client client = new AmazonS3Client(RegionEndpoint.USEast1))
{
GetObjectResponse getObjRespone = client.GetObject("bucketname", "filename.xlsx");
MemoryStream stream = new MemoryStream();
getObjRespone.ResponseStream.CopyTo(stream);
return stream;
}
}
I tried to add in FileStream inputStream = getobject() as FileStream; but it told me that it could not read a null value.
If replace the getobject() in the excelEngine.Excel.Workbooks.Open(getobject()); with a local copy of the file it does work and edit the file correctly.
Anyone have any ideas?
Thanks!