Evitar la notación exponencial de números grandes al importar desde HTML
Contents
[
Hide
]
A veces tu Html contiene números como 1234567890123456 que son más largos que 15 dígitos y cuando importas tu HTML a un archivo de excel, estos números se convierten en notación exponencial como 1.23457E+15. Si quieres que tu número se importe tal como es y no se convierta en notación exponencial, entonces por favor usa la propiedad HTMLLoadOptions.KeepPrecision y cámbiala a true mientras importas tu HTML.
El siguiente código de muestra explica el uso de la propiedad HTMLLoadOptions.KeepPrecision. La API importará el número tal como es sin convertirlo en notación exponencial.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Sample Html containing large number with digits greater than 15 | |
string html = "<html><body><p>1234567890123456</p></body></html>"; | |
// Convert Html to byte array | |
byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(html); | |
// Set Html load options and keep precision true | |
HtmlLoadOptions loadOptions = new Aspose.Cells.HtmlLoadOptions(LoadFormat.Html); | |
loadOptions.KeepPrecision = true; | |
// Convert byte array into stream | |
MemoryStream stream = new MemoryStream(byteArray); | |
// Create workbook from stream with Html load options | |
Workbook workbook = new Workbook(stream, loadOptions); | |
// Access first worksheet | |
Worksheet sheet = workbook.Worksheets[0]; | |
// Auto fit the sheet columns | |
sheet.AutoFitColumns(); | |
// Save the workbook | |
workbook.Save(outputDir + "outputAvoidExponentialNotationWhileImportingFromHtml.xlsx", SaveFormat.Xlsx); |