Hi All,

I cannot export big numbers to excel. I am using POI jar files for jsp to excel export. Here i am pasting my source code.

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Export to Excel</title>
    </head>
    <body>
       <table cellpadding="3" cellspacing="3" border="1">
            <tr>
                <th>9 Digits</th>
                <th>18 Digits</th>
                <th>27 Digits</th>
            </tr>
                <tr>
                    <td>123456789</td>
                    <td>123456789123456789</td>
                    <td>123456789123456789123456789</td>
                </tr>
        </table>        
        <a href="exportData.jsp" >Export to Excel</a>
    </body>
</html>

exportData.jsp

<%@page contentType="application/vnd.ms-excel" pageEncoding="UTF-8"%> 
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <table cellpadding="3" cellspacing="3" border="1">
            <tr>
                <th>9 Digits</th>
                <th>18 Digits</th>
                <th>27 Digits</th>
            </tr>
                <tr>
                    <td>123456789</td>
                    <td>123456789123456789</td>
                    <td>123456789123456789123456789</td>
                </tr>
        </table>
    </body>
</html>

Output
9 Digits 18 Digits 27 Digits
123456789 1.23457E+15 1.23457E+26

Kindly help me to resolve this issue

--
Vinith

This is how very large numbers are by default displayed in an excel file. Try pasting the same number (123456789123456789123456789) in a fresh excel worksheet and the result should probably be the same. You need to set the column/cell type of that excel sheet to "Text" instead of "General" which is selected by default. Look into the API of your excel exporting library for setting the same. In excel, this can be done by right clicking the cell/column -> selecting format cells -> Text.

apart from the EXCELL work, if you need all decimal in jsp page..

use BigDecimal class in java....

Hi all,

Thanks a lot for your help.

I have resolved the issue, i just converted number to string.

<%@page contentType="application/vnd.ms-excel" pageEncoding="UTF-8"%> 
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
<%
    String bigNum = "'123456789123456789123456789'";
    String rps = "&nbsp;";
    String ss1= bigNum.replaceAll("'",rps);
%>
        <table cellpadding="3" cellspacing="3" border="1">
            <tr>
                <th>9 Digits</th>
                <th>18 Digits</th>
                <th>27 Digits</th>
                <th>Corrected</th>
            </tr>
                <tr>
                    <td>123456789</td>
                    <td>123456789123456789</td>
                    <td>123456789123456789123456789</td>
                    <td><%out.println(ss1);%></td>
                </tr>
        </table>
    </body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.