قراءة ملف CSV بترميزات متعددة

توفر Aspose.Cells خاصية TxtLoadOptions.IsMultiEncoded التي يجب أن تقوم بضبطها على true لتحميل ملف CSV الخاص بك بترميزات متعددة بشكل صحيح.

يوضح اللقطة الشاشية التالية ملف CSV عينة يحتوي على سطرين. السطر الأول بترميز ANSI والسطر الثاني بترميز Unicode.

ملف الإدخال
todo:image_alt_text

توضح اللقطة الشاشية التالية ملف XLSX المحول من ملف CSV المذكور أعلاه من دون ضبط خاصية TxtLoadOptions.IsMultiEncoded على true. كما ترون، لم يتم تحويل النص Unicode بشكل صحيح.

ملف الإخراج 1: لم يتم اتخاذ إجراءات للتعامل مع الترميز المتعدد
todo:image_alt_text

توضح اللقطة الشاشية التالية ملف XSLX المحول من ملف CSV المذكور أعلاه بعد ضبط خاصية TxtLoadOptions.IsMultiEncoded على true. كما ترون، تم تحويل النص Unicode بشكل صحيح الآن.

ملف الإخراج 2: تم تعيين IsMultiEncoded على true
todo:image_alt_text

أدناه الكود النموذجي الذي يحول ملف CSV أعلاه إلى صيغة XLSX بشكل صحيح.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
string filePath = dataDir + "MultiEncoded.csv";
// Set Multi Encoded Property to True
TxtLoadOptions options = new TxtLoadOptions();
options.IsMultiEncoded = true;
// Load the CSV file into Workbook
Workbook workbook = new Workbook(filePath, options);
// Save it in XLSX format
workbook.Save( filePath + ".out.xlsx", SaveFormat.Xlsx);

مقالات ذات صلة