CSV import creating incorrect cell format using PreferredParsers

Hi,

I have a strange but reproducible problem when creating a workbook from a csv using TxtLoadOptions.PreferredParsers.

My first column is in quotes and I want it to be treaded as a string and I have a customer parser for it. The second column has a date not in quotes.

"23/09/2018",22/09/2018

In the scenario above, the first becomes a string and the second column becomes a date.

"22/09/2018",22/09/2018

However, if the second column has the same value as the first, it makes column one and two both strings. It seems to say, hey this column has the same value as one of the previous ones in this row, I’ll assume the column type is the same even though they have different parsers.

This definitely seems like a bug to me. Any have an thoughts/ideas?

Full code below.

Thanks

fxm

class Program
{
    static void Main(string[] args)
    {
        LoadFormat oLoadFormat = LoadFormat.Excel97To2003;
        TxtLoadOptions oTxtLoadOptions = new TxtLoadOptions(oLoadFormat);              
        oTxtLoadOptions.Separator = Convert.ToChar(",");            
        oTxtLoadOptions.Encoding = System.Text.Encoding.UTF8;
        oTxtLoadOptions.ConvertDateTimeData = true;
        
        ICustomParser[] oCustomParser = new ICustomParser[2];
        oCustomParser[0] = new TextParser();
        oTxtLoadOptions.PreferredParsers = oCustomParser;

        Aspose.Cells.Workbook oExcelWorkBook = new Aspose.Cells.Workbook("testOk.csv", oTxtLoadOptions);

        Console.WriteLine("testOk.csv"); //"23/09/2018",22/09/2018
        Aspose.Cells.Cell oCell = oExcelWorkBook.Worksheets[0].Cells["A1"];
        Console.WriteLine("A1: " + oCell.Type.ToString() + " - " + oCell.DisplayStringValue);            

        oCell = oExcelWorkBook.Worksheets[0].Cells["B1"];
        Console.WriteLine("B1: " + oCell.Type.ToString() + " - " + oCell.DisplayStringValue);

        Console.WriteLine("");
        Console.WriteLine("");


        oExcelWorkBook = new Aspose.Cells.Workbook("testNotOk.csv", oTxtLoadOptions);
        Console.WriteLine("testNotOk.csv"); //"22/09/2018",22/09/2018

        oCell = oExcelWorkBook.Worksheets[0].Cells["A1"];
        Console.WriteLine("A1: " + oCell.Type.ToString() + " - " + oCell.DisplayStringValue);

        oCell = oExcelWorkBook.Worksheets[0].Cells["B1"];
        Console.WriteLine("B1: " + oCell.Type.ToString() + " - " + oCell.DisplayStringValue);

        Console.ReadKey();
    }
}

class TextParser : ICustomParser
{
    public object ParseObject(string value)
    {   
        return value;
    }
    public string GetFormat()
    {
        return "";
    }
}

@fxm,

Thanks for the sample code and details.

Could you try instantiating another parser for the second column where you need to parse it to DateTime value if it makes any difference.

Thanks. I tried that but the result is the same. In the second example the parser ParseObject method isn’t called at all.

@fxm,

You are right, it looks like the second parser was not used. We will analyse your issue further and then log appropriate ticket for the issue. We will get back to you soon.

Thanks @Amjad_Sahi

@fxm,

We have evaluated your scenario/ case in detail and found the issue as you have described. Using the second parser does not make any difference or even called as you pointed out. We have logged a ticket with an id “CELLSNET-46382” for your issue.

Once we have an update on it, we will let you know here.

Thanks again @Amjad_Sahi

@fxm,

This is to inform you that we have fixed your issue now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

@fxm,

Please try our latest version/fix: Aspose.Cells for .NET v18.9.5

Your issue should be fixed in it.

Let us know your feedback.

The issues you have found earlier (filed as CELLSNET-46382) have been fixed in Aspose.Cells for .NET v18.10. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi