Export jsp content to Excel -- how to keep leading zero?

Hi:
I am trying to export a JSP content to Excel by using
response.setContentType( "application/vnd.ms-excel" );
response.setHeader( "Content-disposition", "attachment; filename=pc.xls" );
it was working great except my jsp has a field whose value consist of leading zero. i.e. 000XXX. Excel strips the leading zero, but I would like to keep them. Please advise.

hi Chang,
Can you please check my thread http://forum.java.sun.com/thread.jspa?threadID=737238&tstart=0
I think you might know the answer since it is similar functionality but for text files.
Thanks !

Similar Messages

  • How to keep leading Zeros in a CSV file

    Hi All -
    I am trying to keep leading zeros in CSV file. Ex. I need 00001 but not just 1. I tried formatting the cells but not getting saved. Any advise please.
    Thanks.

    Dear Super Man  ,
    Try using ALPHA Conversion Routine
    ALPHA Conversion Routine
    The ALPHA conversion is used in the BW system for each presetting for character characteristics. The ALPHA conversion routine is registered automatically when a characteristic is created. If you do not want to use this routine, you have to remove it manually.
    The ALPHA conversion routine is used, for example, with account numbers or document numbers
    For more details
    http://help.sap.com/saphelp_nw04/helpdata/en/9b/f9c18f5a07f0459127e9676ae22a54/frameset.htm
    Hope it helps
    Regards
    Bala

  • How to keep leading zeros using SAP_CONVERT_TO_XLS_FORMAT

    my leading zeros  drop when download using FM-SAP_CONVERT_TO_XLS_FORMAT, how to fix it?

    Hi,
    You can try as below.
    Let's for the 10 digit numeric field, using the function module CONVERSION_EXIT_ALPHA_INPUT, you can get the 10 digit number with leading zeroes.
    Now if you declare the char of 10 in length field in the internal table will be replaced with the above value.
    Now it will be downloaded as required.
    Regards,
    Nishant Malhotra

  • How to keep leading zeros in numeric Keynote entries?

    When I try to enter numbers that start with zeroes in a table, Keynote removes the zeroes. For instance, I type 007 and it gets "corrected" to 7. Also, for instance, when i type false in lower case, it gets changed to FALSE.
    How do I stop this? I found the Auto-correction tab in Preferences, but everything is unchecked there except for the things that deal with email and hyperlink underlining.

    Ok, naturally I found it after I posted the question. I go to Table in the inspector window and change Cell Format from Automatic to Text.

  • 500 internal server error while Export wedbdynpro content into Excel.

    Hi Experts,
    my requirement is export webdynpro content into excel sheet, so for this what i have did is
    First step:
    ) created an Extneral library DC
    2) imported the JARs to the libraries folder of the External Library DC project
    3) Right-click on each of the JARs imported to the project and added them to the public part.
    Second step:
    1) Createed a new Reuse Web Dynpro DC
    2) Created a new public part, selecting the "Can be packaged into other build results" option
    3) extrcted the full content (folders and class files) to root folder
    4) Imported the folders and files to the src/packages folder
    5)binded the attributes, created 3 methods and writen the code for those methods.
    Third Step:
    1) created one more EXPORT EXCEL DC
    2) ADDED LIB jar dc and Reuse DC IN used dc's
    3) created usedwebdynpo component and binded attributes to Table VIEW and writen the code for exposing table values.
    After this build and deployed i am getting clasnot found error
    so what i have did now is
    Fourth step:
    1)Created "J2EE Library DC"
    2) Refered "External Library DC" into J2EE Library DC.
    3) Deployed "J2EE Library DC"
    4) Refered this one in my Web Dynpro DC by giving Library Reference.
    now when i deploy and run what happend i am getting
    500 Internal Server Error SAP J2EE Engine/7.01 
    Application error occurred during request processing.
    Details:   com.sap.tc.webdynpro.services.sal.core.DispatcherException: Failed to start deployable object sap.com/export_file_excel_7.
    Exception id: [00215E78C4C0006D00000AD9000E00F00004887F642A32FE]
    Any one can tell what could be the problem.

    Thanks for sharing the solution.

  • Error Exporting Table Content into Excel

    Hi there,
    I have code that reads a TableView and exports its content into excel file. The code is running right now in an iView that is stored in a protal role. The code has been developed using PDK. I'm running portal 6.0 SP16.
    Here is what the code does:
    1. Reads the content of the table and stores it in an HSSFSheet inside an HSSFWorkbooK object.
    2. Gets HttpServletResponse from the portal request and updates its content type and headers
    HttpServletResponse response = ((IPortalComponentRequest)getRequest()).getServletResponse(true);
    response.setContentType("application/vnd.ms-excel");
    response.setHeader("Content-Disposition", "attachement;filename="EmployeeEntitlementRpt.xls"");
    3. Writes the excel file to the response output stream.
    ServletOutputStream fileOut = null;
    try{
         fileOut = response.getOutputStream();
         wb.write(fileOut);
         fileOut.close();
    } catch(IOException ie){
         throw new PortalRuntimeException("IOException when getting output steam from response, writing to the outputstream or closing it.", ie);
    The code gives me the following error message, if invoked from the iview inside the detailed navigation.
    <b>"Internet Explorer cannot download ...ge!2fcom.sap.portal.innerpage from portald.global.ad
    Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later."</b>
    However, when I navigate to the same iView and open it in a new window, the code functions as expected.
    This is the URL to the iView when opened inside the detailed navigation: https://companyserver.global.ad/irj/servlet/prt/portal/prtpos/pcd!253aportal!255fcontent!252fevery!255fuser!252fgeneral!252fdefaultDesktop!252fframeworkPages!252fframeworkpage!252fcom!252esap!252eportal!252einnerpage!7b!3b2!7d.com!252esap!252eportal!252edynamicNavigationArea!7bHideMode!7d_com!252esap!252eportal!252etargetsiView!7bHideMode!7d_com!252esap!252eportal!252etargetsiView!255f!7bHideMode!7d-/prttarget/com!252enexeninc!252etots!252eiv_entitlement_report.content/prteventname/HtmlbEvent/prtroot/pcd!3aportal_content!2fevery_user!2fgeneral!2fdefaultDesktop!2fframeworkPages!2fframeworkpage!2fcom.sap.portal.innerpage
    This is the URL to the iView when opened in a new window:
    https://companyserver.global.ad/irj/servlet/prt/portal/prtroot/com.sap.portal.pagebuilder.iviewmodeproxy?iview_id=pcd%3aportal_content/com.nexeninc.fld_nexen_content/fld_all_users/fld_time_off_tracking/fld_administrators/com.nexeninc.tots.ro_administrator/com.nexeninc.tots.ws_user_components/com.nexeninc.portal.navigation.ws_my_workspace_my_applications/com.nexeninc.portal.navigation.ws_my_workspace/fld_general_applications/fld_track_time_off/fld_admin/com.nexeninc.tots.iv_entitlement_report&iview_mode=default

    Hi,
    In the iView properties, for the property Entry Point, mark the property as yes instead of the default no. May be this could help u.
    Regards,
    Sujana

  • How to remove leading zeros from variable

    hi,
       how to remove leading zeros from variable like it_vbap-matnr.
    value in it_vbap-matnr is 000000000000000358
    i want to remove leading zeros so that it become 358
    regards
    deepak

    You can use Function Module <b>'CONVERSION_EXIT_MATN1_OUTPUT'</b>
    This Function Module will eliminate leading Zeros.
    For each MATNR Value read form DB Table,u can eliminate Leading zeros and then modify ur Internal table.
    I think u will not get leading Zeros into utr Internal table when u read from VBAP.
    Bcoz MATNR in VBAP itself have Conversion routine.
    If u r getting leading zeros,U can use following Logic.
    tables:
      vbap.
    data:
       t_vbap like standard table of vbap.
    select matnr
    from vbap
    into corresponding fields of table t_vbap.
    loop at t_vbap into vbap.
      CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
          EXPORTING
            INPUT         =  vbap-matnr
          IMPORTING
            OUTPUT        =  vbap-matnr
      modify t_vbap from vbap transporting matnr.
    endloop.
    Hope this will work.....

  • How to delimit leading zero in vendor number in OO ABAP ALV without using conversion routine

    Hi,
    How to delimit leading zero in OO ABAP ALV without using conversion routine, because I have many fields like vendor, customer, material number etc..
    How to address this leading zero.
    I appreciate your quick response.
    Regards,
    Nalini S.

    Hi Nalini,
    Delimiting leading zeros in fields has to be done via conversion routines, as suggested by Vadamalai you need to pass on the conversion routine name in you field catalog variable.
    Now as to which object oriented approach are you using to have your table contents display in ALV as it matters  -
    Using FACTORY method of CL_SALV_TABLE class, or
    Using SET_TABLE_FOR_FIRST_DISPLAY method of CL_GUI_ALV_GRID class.
    Using FACTORY method of CL_SALV_TABLE will do your own work, no need to apply any conversion routines or set long/medium/short text for columns as we do in field catalogs!
    Cheers,
    Varun

  • How to suppress leading zeros

    Hi,
            How to suppress leading zeros in a character string.
    Thank you.

    hi,
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
                EXPORTING
                  input  = str1
                IMPORTING
                  output = str1.
    Example:
    input = 00000000000123
    output = 123
    rgds
    Anver

  • Convert hex to Decimal and keep leading zeros..

    Hi,
    I hope you can help?
    How to convert hex to Decimal and keep leading zeros
    I read 002C, hex, and I want to convert it to 0044 decimal.
    sscanf (MyNum, "%4x", &DecNum); will only give me 44.
    It have been working up till I started to get leading zeros.
    We will always have a 4 digit hex input in a range
    We must have the leading 00 in this case.
    How is this best done?
    Thanks for the help
    Simon
    Solved!
    Go to Solution.

    Hi,
    I don't really understand your problem. Is this stuff what you need ?
    int main (int argc, char *argv[])
    const char MyNum[] = "002C";
    int DecNum;
    sscanf (MyNum, "%4x", &DecNum);
    printf ("%04d", DecNum);
    getchar ();
    return 0;
    "0044" appears on standard output when printf function executes...

  • Help keeping leading zero String- Long

    Hello
    I wonder lets say I have a String "09090" how do I convert this String to a Long and keeping leading zero so the Long is 09090?
    /D_S

    Numeric types like Long (or long) are numbers, not strings, so they have no formatting notions like leading zeroes. If you want to maintain the string "09090" keep the string around, even if you have to parse it as well. By the way, you forgot to describe what your goal is, what you are trying to do and what it has to do with leading zeroes.
    One more: Why does this print false?
    System.out.println(07070 == 7070);Hint: this generates a compile-time error:
    System.out.println(09090 == 9090);

  • How to remove leading zero from Material Number

    Hello Everyone,
    I need to figure it out how to remove leading zero from material number. Cureently extractor is sending material number as 100663. But when comes into BI i am getting as "000000000000100663" and similariy in report it is appearing as "000000000000100663". Now my client wants me to exclude preceeding zero for a material in all the reports.
    Is there any setting in query desinger to handle this issure or in the backend.
    Need your inputs.
    Thanks,
    Lasya.

    Hi
    you can use the function Module
    CONVERSION_EXIT_ALPHA_OUTPUT in the start routine
    to test this go to SE37  --- give the CONVERSION_EXIT_ALPHA_OUTPUT -
    >display -
    > F8
    in the input give 000000456
    and execute
    the out put will be 456
    for getting Zeros you can use
    CONVERSION_EXIT_ALPHA_INPUT--- to remove leading zeros
    Santosh
    Edited by: Santhosh Nagaraj on Oct 29, 2009 10:52 PM
    Edited by: Santhosh Nagaraj on Oct 29, 2009 10:54 PM

  • How to remove leading zeros for an item number within quickviewer

    how to remove leading zeros for an item number within quickviewer. Pls help

    ask your abap guy to do  it. not portal guys business.

  • How to retain leading zeros in an excel sheet

    Hi,
    In my application I need to export the response from a struts action class to an excel sheet. I have done the coding but while exporting to the excel , the leading zeros are getting truncated. If the value is '01' it is displayed as '1' only.
                    response.setContentType("application/text");
                             response.setHeader("Content-disposition",
                                       "Attachment;filename=\"export.xls\"");
                             response.getOutputStream().println(data);
                             response.getOutputStream().flush();This is the code which I am using to export all the data to the excel.Here the variable data is a String .
    Kindly help on this issue.
    Thanks in advance...
    Edited by: 2569 on Jan 10, 2008 8:59 PM
    Edited by: 2569 on Jan 10, 2008 9:51 PM

    2569 wrote:
    I tried that way also, but its not working. I have defined all the values as strings only. Thanks for ur replyWhich API are you using to write excel files? You can try to surround the numeric string value with singlequotes (or escaped doublequotes)String numericString = "'01'";so that Excel interprets it as string.

  • How to keep lead selections in alv table...

    Hi experts.
    I made a alv.
    A logic  in wdmodifyview is following..
    METHOD wddomodifyview .
      IF first_time EQ abap_true.
        wd_comp_controller->set_alv_config( ).
      ENDIF.
      wd_this->set_maktx( ).  "<- for displaying maktx
    ENDMETHOD.
    When I want to select a line, do not selected.
    I know because of "wd_this->set_maktx( )." sentence.
    But I want to select multi lines in above condition...
    How to keep selected lines in alv?
    Help me please.
    Thanks.
    Regards.

    What logic is taking place in wd_this->set_maktx( )?  It is pretty difficult to say what is causing the issue without knowing what code you are executing?  If you are resetting the context bound to the ALV, that would explain why you are losing your selections.

Maybe you are looking for

  • Problem with application developed with vtapi(Vt Systems) - events

    Hello! I'm developing aplication based on api prepared by VT Systems (http://www.cmsfx.com/en/trading-software/download-vt-trader/download-vt-trader-api/). This api is used to perform forex transactions. I've written a Web Service which connects with

  • How can I re-org my Exchange folders on my iPhone?

    The Exchange mail client on the iPhone shows the Exchange folders as they are in Exchange.  Yesterday, out of the blue, I checked my mail and found that Sent Items and Drafts were at the top and I was thrilled, as this prevented me from having to scr

  • Impossible (?) to link to Named Destination/Bookmark in Local PDF from PDF?

    Goal: Very simple... in a PDF, click on a link that (a) opens a second PDF on local drive, and (b) navigates to a named destination or bookmark in that second PDF... just like our normal everyday HTML links work, and even Word itself does this. Accor

  • Software update unexpected error on installation

    I was updating with the latest combo updater to 10.4.11 from 10.4.8, and iphoto 6.0.6 and backup 3.1.2 and I get a message that an error occurred and the software couldn't be installed. Quit software update and try from Finder. I did with same result

  • Need to access TestStand Sequence Step Parameters from Excel Macro

    Trying to create an EXCEL spreadsheet containing a list of all steps in a TestStand Sequence including Parameter names and types. How can I access the parameter names and types from EXCEL Visual Basic? It seems the API provides access to sequence par