Exportieren Sie Excel-Daten ohne Formatierung in DataTable
Manchmal möchten Benutzer Excel-Daten ohne Formatierung in eine Datentabelle exportieren. Wenn beispielsweise eine Zelle den Wert 0,012345 hat und so formatiert ist, dass zwei Dezimalstellen angezeigt werden, wird der Benutzer beim Exportieren von Excel-Daten in eine Datentabelle als 0,01 und nicht als 0,012345 exportiert. Um dieses Problem zu lösen, hat Aspose.Cells bereitgestelltExportTableOptions.FormatStrategy Eigenschaft, die einen dieser drei Werte annehmen kann
- CellValueFormatStrategy.CellStyle
- CellValueFormatStrategy.DisplayStyle
- CellValueFormatStrategy.None
Wenn Sie es einstellen möchtenCellValueFormatStrategy.None, dann werden die Daten ohne Formatierung exportiert.
Beispielcode
Das folgende Beispiel erläutert die Verwendung vonExportTableOptions.FormatStrategyEigenschaft zum Exportieren von Excel-Daten mit und ohne Formatierung.
Konsolenausgabe
Unten finden Sie die Konsolen-Debug-Ausgabe des obigen Beispielcodes
Cell String Value: 0.01
Cell String Value without Format: 0.012345
Export Data Table with Format Strategy as Cell Style: 0.01
Export Data Table with Format Strategy as None: 0.012345