Excel files are stored in azure blob containers. They are downloaded without incident in IE but in Chrome the page displays this message (and in Canary it crashes):
This file appears corrupt
and provides a link to download it and all is well from that point. I've tried setting the content-type to different excel formats but the result is the same.
Here's the blob code:
MemoryStream memoryStream = new MemoryStream();
CreateFile(memoryStream, grid);
memoryStream.Position = 0;
var blockBlob = container.GetBlockBlobReference(randomFileName);
blockBlob.Properties.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
blockBlob.DeleteIfExists();
var options = new BlobRequestOptions()
{
ServerTimeout = TimeSpan.FromMinutes(10)
};
try
{
blockBlob.UploadFromStream(memoryStream, null, options);
}
catch (Exception e)
{
_logger.Error("Uploading excel file: Error: {0}", e.Message);
}
return new Uri("https://myblobs.blob.core.windows.net/" + "containername/" + randomFileName);
You missed
blockBlob.SetProperties();
Try this:
Note that for
.xls
files you need to setcontent-type
toapplication/vnd.ms-excel
.FYI: If you want to update property values in existing blob you need to fetch the current values, set the property that we want to update and call
SetProperties
on the BLOB.Example: