Excel Export Error

Excel Export Error

WarrenCoyWarrenCoy Posts: 5Questions: 0Answers: 0

Link to test case:

Error messages shown: Excel shows Alert dialog: We found a problem with some content...
Description of problem: For the first row only it gives the error and shows NaN instead of the part number in excel

Replies

  • WarrenCoyWarrenCoy Posts: 5Questions: 0Answers: 0

    Example HTML of the table:

    <table id="capsResults" class="table table-striped" style="width:100%">
        <thead>
            <tr>
                <th>Part</th>
                <th>Description</th>
                <th>Capability</th>
            </tr>
        </thead>
        <tbody>
        
            <tr>
                <td>9807-51-01</td>
                <td>ELEVATOR FEEL INDICATOR</td>
                <td>YES</td>
            </tr>
        </tbody>
    </table>
    
  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    Many thanks! Our Excel formatter is treating that as an ISO8601 date! The result is that the 51 goes into Date.parse as the month which of course it rejects outright.

    I've tightened up the regex (commit) to address this - thanks for letting me know about it!

    The nightly will rebuild with the change shortly.

    Allan

  • WarrenCoyWarrenCoy Posts: 5Questions: 0Answers: 0

    Is there anyway to flag a cell as a specific type so auto formatting doesn't happen? Would make the result more readable. If a part is just a number it may drop the leading zero (perhaps)?

    With a parts database multiple parts could look like a date but they are not dates or numbers but really strings.

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    Is there anyway to flag a cell as a specific type so auto formatting doesn't happen?

    No sorry. The Excel formatting stuff isn't even exposed publicly, so it can be removed unfortunately. I can add that though (there is even a comment in the code to that effect), or you could modify your copy of the Buttons file to strip this line.

    Allan

  • WarrenCoyWarrenCoy Posts: 5Questions: 0Answers: 0

    Thank you Allan, I will check it out. I use various PHP libraries to do this excel export and the only tweak I had to make was forcing a column to be text and not auto format as a number (granted I have not done a ton of exports) and that was really the only tweak as dates and other formats work great generally.

  • WarrenCoyWarrenCoy Posts: 5Questions: 0Answers: 0

    If I assume YYYY-MM-DD I found a more exact regex at

    https://regexland.com/regex-dates/

    ^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/ 
    

    Which checks for 01-12 for months and 01-31 for days (granted not all months have 31 days). So for this specific issue it works great in avoiding the invalid date (part number).

    Thank you for your help.

Sign In or Register to comment.