I am trying to convert an Excel file to an HTML file which I later display on the page as a preview. Everything works well except one element. I display the HTML file in the pop-up window and it does not fit in completely. How to make the generated HTML file match the width of the window? My point is that I do not have to scroll the page horizontally (only vertically like a classic scroll).
private void ConvertExcelToHtml(Stream stream, string fileName, string directory, string virtualDirectory, bool force)
{
var htmlPath = Path.Combine(directory, $"{fileName}.html");
if (force == false && System.IO.File.Exists(htmlPath))
{
return;
}
log.DebugFormat("Converting Excel=>HTML: '{0}'", fileName);
var document = new Workbook(stream);
this.RemoveHeader(document);
var htmlSaveOptions = new Aspose.Cells.HtmlSaveOptions(SaveFormat.Html)
{
HiddenColDisplayType = HtmlHiddenColDisplayType.Remove,
HiddenRowDisplayType = HtmlHiddenRowDisplayType.Remove,
AttachedFilesDirectory = directory,
ExportActiveWorksheetOnly = true,
};
htmlSaveOptions.ImageOptions.ImageFormat = ImageFormat.Png;
document.Save(htmlPath, htmlSaveOptions);
var htmlDoc = new HtmlDocument();
htmlDoc.Load(htmlPath);
htmlDoc.Save(htmlPath);
}