Hello,
I’m trying to export an Excel Worksheet to HTML but after checkin the output I don’t find the correct width of the columns (“Width” without the unit and style with “Width” in pt)
Could you explain me if I’m using the wrong method ?
Code:
Workbook wrk = new Workbook(@“C:\test\Book1.xlsx”);
using (var stream = new MemoryStream(1))
{
var opts = new Aspose.Cells.HtmlSaveOptions
{
ExportGridLines = false,
ExportActiveWorksheetOnly = true,
HtmlCrossStringType = HtmlCrossType.MSExport,
ExportBogusRowData = false,
ExportImagesAsBase64 = true,
ExportCellCoordinate = true
};
wrk.Save(stream, opts);
byte[] arr = stream.ToArray();
var html = Encoding.UTF8.GetString(arr);
}
Console.WriteLine(“Column 3”);
Console.WriteLine($“Width {wrk.Worksheets[0].Cells.GetColumnWidth(3)}”);
Console.WriteLine($“Width {wrk.Worksheets[0].Cells.GetColumnWidthPixel(3)}”);
Console.WriteLine(“Column 4”);
Console.WriteLine($“Width {wrk.Worksheets[0].Cells.GetColumnWidth(4)}”);
Console.WriteLine($“Width {wrk.Worksheets[0].Cells.GetColumnWidthPixel(4)}”);
Console.WriteLine(“Column 5”);
Console.WriteLine($“Width {wrk.Worksheets[0].Cells.GetColumnWidth(5)}”);
Console.WriteLine($“Width {wrk.Worksheets[0].Cells.GetColumnWidthPixel(5)}”);
Console.WriteLine(“Column 6”);
Console.WriteLine($“Width {wrk.Worksheets[0].Cells.GetColumnWidth(6)}”);
Console.WriteLine($“Width {wrk.Worksheets[0].Cells.GetColumnWidthPixel(6)}”);
Console results:
Column 3
Width 9,38
Width 80 → PX
Column 4
Width 14,38
Width 120 → PX
Column 5
Width 6,88
Width 60 → PX
Column 6
Width 19,38
Width 160 → PX
HTML:
image.png (54.7 KB)
Why the table width is also not correct ?
Thanks
Regards
Davide
Book1.zip (7.7 KB)