MiniExcel icon indicating copy to clipboard operation
MiniExcel copied to clipboard

Problem with multi-line when using Query func

Open Sniky83 opened this issue 2 years ago • 2 comments

Excel Type

  • [x] XLSX
  • [x] XLSM
  • [X] CSV
  • [x] OTHER

Upload Excel File

e.g : .NET Fiddle

MiniExcel Version

1.31

Description

I wanted to import a CSV file in my project by reading the infos of the file and I jumped lines in my cells and I've seen that I would have more lines found than expected.

So when you put in a cell a retrun line you have a trouble, your code create a new object instead of adding the cell with the x jumping lines in the current object.

Check the .NET fiddle link and run it to understand easily what i'm meaning.

Sniky83 avatar Jun 21 '23 15:06 Sniky83

MiniExcel image

CSV helper :

image

Office image

image

Updated : We need to overwrite readline method to check the row contains the \n and " or not

image

        [Fact]
        public void TestIssue507()
        {
            var path = PathHelper.GetTempFilePath("TestIssue142.csv");
            var values = new[] {
                new { A = "Github", B = DateTime.Parse("2021-01-01") },
                new { A = "Microsoft \nTest", B = DateTime.Parse("2021-02-01") }
            };

            var config = new CsvConfiguration()
            {
                AlwaysQuote = true
            };

            // create 
            using (var stream = File.Create(path))
                stream.SaveAs(values, excelType: ExcelType.CSV, configuration: config);

            Console.WriteLine(File.ReadAllText(path));

            // read
            var getRowsInfo = MiniExcel.Query(path, true, excelType: ExcelType.CSV, configuration: config).ToArray();
        }

shps951023 avatar Jun 22 '23 06:06 shps951023

The problem is when I want to use the Query Method from your lib, it's not working, "Microsoft Test" doesn't go in the same object but it is split in two differents object which is wrong. Take a look at the fiddle back. When I dump the result and look at the Console.

Sniky83 avatar Jun 22 '23 07:06 Sniky83