我正在使用 aspose.cell 来读取我的 csv 文件,其中 "," 作为列分隔符,单引号 (') 作为文本限定符,换行符作为行分隔符。如下图所示:例如:
'1'.'2','3','4'
'5','6','7','8'
从 aspose.cell 读取时,值(考虑到所有文本值都没有数字)呈现为
1', 2', 3', 4'
5', 6', 7', 8'
文本限定符为双引号 (") 时没有问题。
有人可以帮忙吗,如何将我的带有单引号 (') 的 csv 文件作为 aspose.cell 的文本限定符?
谢谢
TxtLoadOptions options = new TxtLoadOptions( LoadFormat.CSV)
options.ConvertNumericData = false;
options.ConvertDateTimeData = false;
options.SeparatorString=",";
// reading aspose license reading, code removed
//stream is ----stream reader
Workbook workBook = new Workbook(stream, options);
workBook.Settings.CheckExcelRestriction = false;
var workSheet = workBook.Worksheets[workBook.Worksheets.ActiveSheetIndex];
Console.WriteLine( workSheet.Cells[0, 0].Value.ToString());
Console.WriteLine( workSheet.Cells[0, 1].Value.ToString());
Console.WriteLine( workSheet.Cells[0, 2].Value.ToString());
Console.WriteLine( workSheet.Cells[0, 3].Value.ToString());
Console.WriteLine( workSheet.Cells[1, 0].Value.ToString());
Console.WriteLine( workSheet.Cells[1, 1].Value.ToString());
Console.WriteLine( workSheet.Cells[1, 2].Value.ToString());
Console.WriteLine( workSheet.Cells[1, 3].Value.ToString());