in reply to Re: excel format problem
in thread excel format problem

I don't think this will work, but, on the other hand, Excel has a HEXDEC conversion function which might work. But I really think that converting the hex number into decimal notation in Perl prior to loading it to Excel, as suggested by choroba will be much easier.

Replies are listed 'Best First'.
Re^3: excel format problem
by davies (Monsignor) on Sep 03, 2014 at 17:43 UTC

    Excel's hex converter certainly used to be limited to numbers less then 512. I also believe that the OP is using Spreadsheet::WriteExcel or something from that stable rather than Win32::OLE, otherwise I would rush my BigInt xla out & suggest he used that, but I understand that it's a problem importing modules into Excel files using S:WE or its derivatives.

    Regards,

    John Davies

      Hi, thank you, I did not know the Excel conversion function was limited to 512, but I did not see anyway an easy way to use it within the context of a Perl program. Just another good reason to convert the numbers into decimal notation using Perl, before populating the spreadsheet (choroba's suggestion).
      Actually, I think that literally putting "0x" at the beginning made it from a number to a string and now Excel leaves it alone.

        Yes, but now Excel will ignore it as a number. For example, with cell B4 containing =SUM(B1:B3):

        AB
        1 1
        2 0x2
        3 3
        4 Total: 4

        — the total is 4, not 6 as expected. As a rule, numerical data entered into an Excel spreadsheet should be available to be used as numerical data — that’s what a spreadsheet is for, after all! So, prefer choroba’s approach given above.

        Hope that helps,

        Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

      Actually, this seems to have worked:
      $hex_data = "0x".$hex_data;
      That forces an 0x on the values that I print to Excel. That seems to be working.