الاحتفاظ بالفواصل للفئات الفارغة أثناء تصدير جداول البيانات إلى تنسيق CSV باستخدام C++
الاحتفاظ بالفواصل للصفوف الفارغة أثناء تصدير جداول البيانات إلى تنسيق CSV
توفر Aspose.Cells القدرة على الاحتفاظ بفواصل الأسطر أثناء تحويل جداول البيانات إلى تنسيق CSV. لهذا، يمكنك استخدام خاصية GetKeepSeparatorsForBlankRow() من فئة TxtSaveOptions. GetKeepSeparatorsForBlankRow() هي خاصية من نوع boolean. للحفاظ على الفواصل للفقرات الفارغة أثناء تحويل ملف Excel إلى CSV، اضبط الخاصية GetKeepSeparatorsForBlankRow() على true.
يعرض الرمز النموذجي التالي تحميل ملف Excel المصدر. حيث يضبط الخاصية TxtSaveOptions.GetKeepSeparatorsForBlankRow() على true ويحفظه كـ ملف CSV الناتج. تظهر الصورة المجمعة المقارنة بين ملف Excel المصدر، والناتج الافتراضي عند تحويل ورقة العمل إلى CSV، والناتج الناتج عن ضبط GetKeepSeparatorsForBlankRow() على true.
الكود المثالي
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
// Source directory path
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Output directory path
U16String outDir(u"..\\Data\\02_OutputDirectory\\");
// Path of input excel file
U16String inputFilePath = srcDir + u"Book1.xlsx";
// Create a Workbook object and opening the file from its path
Workbook workbook(inputFilePath);
// Instantiate Text File's Save Options
TxtSaveOptions options;
// Set KeepSeparatorsForBlankRow to true to show separators in blank rows
options.SetKeepSeparatorsForBlankRow(true);
// Save the file with the options
workbook.Save(outDir + u"output.csv", options);
std::cout << "File saved successfully as output.csv!" << std::endl;
Aspose::Cells::Cleanup();
}