The problem is that I can't catch the error and offer the user other option, because the library stalls the entire request (I get ERR_CONNECTION_REFUSED from Chrome)
- Code: Select all
public string ExcelAsPNGUrl() {
try {
var TempFolder = @"/Content/Temp/";
var UniquePreviewFileName = ArchivoURL.Replace("/", "_") + ".png";
if (!System.IO.File.Exists( HttpContext.Current.Server.MapPath(TempFolder + UniquePreviewFileName))) {
var workbook = new Spire.Xls.Workbook();
workbook.LoadFromFile(HttpContext.Current.Server.MapPath(ArchivoURL));
var sheet = workbook.Worksheets[0];
sheet.SaveToImage(HttpContext.Current.Server.MapPath(TempFolder + UniquePreviewFileName)); // Here I get a StackOverflow exception
}
return @"/Content/Temp/" + UniquePreviewFileName;
}
catch (Exception) {
// *************************************
// the code never reaches HERE
return "";
}
}
I'm using the latest version 12.2