複数のエンコーディングでのCSVファイルの読み込み

Contents
[ ]

Aspose.CellsはTxtLoadOptions.is_multi_encodedプロパティを提供しており、複数のエンコーディングでCSVファイルを正しくロードするにはtrueに設定する必要があります。

以下のスクリーンショットは、2行を含むサンプルCSVファイルを示しています。1行目はANSIエンコーディングで、2行目はUnicodeエンコーディングです

入力ファイル
todo:image_alt_text

|入力ファイル|

出力ファイル1: 複数のエンコーディングを考慮していない
todo:image_alt_text

上記のCSVファイルから変換されたXLSXファイルを、TxtLoadOptions.is_multi_encodedプロパティをtrueに設定した後のスクリーンショットは以下の通りです。Unicodeテキストが正しく変換されていることがわかります。

出力ファイル2: IsMultiEncodedをtrueに設定
todo:image_alt_text

以下は、上記のCSVファイルを正しくXLSX形式に変換するサンプルコードです。

from aspose.cells import SaveFormat, TxtLoadOptions, Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
filePath = dataDir + "MultiEncoded.csv"
# Set Multi Encoded Property to True
options = TxtLoadOptions()
options.is_multi_encoded = True
# Load the CSV file into Workbook
workbook = Workbook(filePath, options)
# Save it in XLSX format
workbook.save(filePath + ".out.xlsx", SaveFormat.XLSX)