Display excel file on clicking JButton

Hi,
I have a requirement wherein when the user clicks a JButton, an excel file (which is already present in the app), will open, i.e. Excel 2003 / Xp will get started & display that file.
Appreciate any help on this.
Best regards,
AJ

Use the Desktop class to open a file with a system default application:
java.awt.Desktop.getDesktop().open(new File("C:/path/to/whatever.xls"));

Similar Messages

  • Proble with displaying excel file on the PC?

    Hello Friends,
    I have another issue.
    When the user presses push button in my application, I am displaying excel file with data. It is working fine. But... a dummy file is creating always in my desktop with DAT extension. Is there any possiblity not to store on the PC.
    code I used for calling excel file.
      CALL FUNCTION 'WS_EXCEL'
       EXPORTING
            FILENAME = ' '
            SYNCHRON = ' '
           TABLES
                DATA     = ITAB
           EXCEPTIONS
                OTHERS   = 1.
    Could you pls help me not to store the excel file on the desktop/ PC.
    only temporary excel file should display.
    Thanks in advance
    Raghu

    WS_excel is obsolette now.
    use MS_EXCEL_OLE_STANDARD_DAT.
    REPORT ZEX_DATATOEXCEL .
    Parameters: P_file like RLGRAP-FILENAME.
    data : begin of int_head occurs 0,
    Filed1(20) type c,                     " Header Data
    end of int_head.
    data : begin of int_data occurs 0,
    Field1(20) type c,                     " Data
    Field2(20) type c,
    Field3(20) type c,
    Field4(20) type c,
    end of int_data.
    int_head-Filed1 = 'Sales Ord'.
    APPEND int_head.
    CLEAR  int_head.
    int_head-Filed1 = 'Sold-to-Party'.
    APPEND int_head.
    CLEAR  int_head.
    int_head-Filed1 = 'Purchase Ord'.
    APPEND int_head.
    CLEAR  int_head.
    int_head-Filed1 = 'Ship-to-Party'.
    APPEND int_head.
    CLEAR  int_head.
    int_data-field1 = '1JOHN'.
    int_data-field2 = '2TOM'.
    int_data-field3 = '3BRAD'.
    int_data-field4 = '4PETER'.
    Append int_data.
    Clear int_data.
    CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
    EXPORTING
    file_name = p_file " path offile where u need to download
    * CREATE_PIVOT = 0
    * DATA_SHEET_NAME = ' '
    * PIVOT_SHEET_NAME = ' '
    * PASSWORD = ' '
    * PASSWORD_OPTION = 0
    TABLES
    * PIVOT_FIELD_TAB =
    data_tab = int_data "internal table with data
    fieldnames = int_head "internal table with header
    EXCEPTIONS
    file_not_exist = 1
    filename_expected = 2
    communication_error = 3
    ole_object_method_error = 4
    ole_object_property_error = 5
    invalid_filename = 6
    invalid_pivot_fields = 7
    download_problem = 8
    OTHERS = 9
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

  • Generate and display excel file

    Hi guys,
    Is there a way to generate and display excel file in sapgui without the need of downloading the excel file to local directory first?
    I found the following 2 ways of doing it, but both require me to download the generated xls file to local directory:
    #1 way:
    1. Generate the xls file using GUI_DOWNLOAD with the filename = 'c:\test.xls'.
    2. Call fm SAP_STARTS_EXCEL and pass in the parameter i_filename = 'c:\test.xls'
    #2 way:
    1. Generate the xls file using GUI_DOWNLOAD with the filename = 'c:\test.xls'.
    2. Upload it back using the below so that i can get it in xstring format.
    CALL FUNCTION 'GUI_UPLOAD'
         exporting
           filetype =  'BIN'
           filename = 'C:\test.xls'
         tables
           data_tab = itab.
    3. Then pass it to the cl_gui_html_viewer to display it.
    call method html_control->load_data
        exporting
          url          = 'test.xls'
          type         = 'application'
          subtype      = 'vnd.ms-excel'
        importing
          assigned_url = l_url
        changing
          data_table   = l_pdf_data
        exceptions
          others = 1.
    I prefer the #2 way as my program will get wrapped thru ITS server, and it seems the #1 way will not work. So is there any way i can get the excel file to be generated in xstring format so that i can pass to cl_gui_html_viewer straight away to display without having to save to local directory first?
    Any other suggestion apart from the above 2 ways are welcome as well.
    Thanks guys.

    Use function module ALV_XXL_CALL. It will solve ur prob immediately.
    REPORT  ZSKC_ALV_XXL.
    TYPE-POOLS : KKBLO.
    DATA : ITAB LIKE T100 OCCURS 0,
           T_FCAT_LVC TYPE LVC_S_FCAT OCCURS 0 WITH HEADER LINE,
           T_FCAT_KKB TYPE KKBLO_T_FIELDCAT.
    START-OF-SELECTION.
    * Get data.
      SELECT * UP TO 20 ROWS
      FROM   T100
      INTO   TABLE ITAB
      WHERE  SPRSL = SY-LANGU.
      CHECK SY-SUBRC EQ 0.
    * Create the field catalog.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
       EXPORTING
          I_STRUCTURE_NAME             = 'T100'
        CHANGING
          CT_FIELDCAT                  = T_FCAT_LVC[]
        EXCEPTIONS
          INCONSISTENT_INTERFACE       = 1
          PROGRAM_ERROR                = 2
          OTHERS                       = 3.
      CHECK SY-SUBRC EQ 0.
    * make sure you pass the correct internal table name in the field catalog.
      t_fcat_lvC-tabname = 'ITAB'.
      MODIFY T_FCAT_LVC TRANSPORTING TABNAME WHERE TABNAME NE SPACE.
    * Transfer to KKBLO format.
      CALL FUNCTION 'LVC_TRANSFER_TO_KKBLO'
        EXPORTING
          IT_FIELDCAT_LVC                 = T_FCAT_LVC[]
        IMPORTING
          ET_FIELDCAT_KKBLO               = T_FCAT_KKB
       EXCEPTIONS
         IT_DATA_MISSING                 = 1
         IT_FIELDCAT_LVC_MISSING         = 2
         OTHERS                          = 3.
      CHECK SY-SUBRC EQ 0.
    * Call XXL.
      CALL FUNCTION 'ALV_XXL_CALL'
        EXPORTING
          I_TABNAME                    = 'ITAB'
          IT_FIELDCAT                  = T_FCAT_KKB
        TABLES
          IT_OUTTAB                    = ITAB[]
        EXCEPTIONS
          FATAL_ERROR                  = 1
          NO_DISPLAY_POSSIBLE          = 2
          OTHERS                       = 3.
      IF SY-SUBRC <> 0.
      ENDIF.
    It will open the Excel in front of you and populate the cells from your internal table
    with color for Key columns.
    Cheers
    SKC.

  • Display Excel File using OfficeControl

    Hi,
    My requirement is to display and Excel file for approval purpose which is generated by custom ABAP application. After each approval I need to again generate the Excel file with the approval name added and send for next approval.
    Is it possible to download the Excel File to application server and display it on webdynpro screen.
    Please let me know if they are other methods to achieve the same.
    Thank you,
    Ramu N.

    Hi Ramu,
    Yes you can do this by using File upload and  download methods. using this you can upload and download excel files.
    Check this wiki..
    http://wiki.sdn.sap.com/wiki/display/WDABAP/UploadandDownloadfilesinWebdynproABAP
    http://wiki.sdn.sap.com/wiki/display/WDABAP/ExcelFileUploadAndDisplayDataUsingWebDynPro+ABAP
    using office control...Check this...
    How to use element FILE_UPLOAD with element OFFICE_CONTROL
    http://help.sap.com/saphelp_nw2004s/helpdata/en/d1/af8841349e1909e10000000a155106/frameset.htm
    Cheers,
    Kris.
    Edited by: kissnas on May 19, 2011 6:36 AM

  • Display excel file from jsp

    hi i am trying to read an excel file from a location on the app server and display it in the browser (ie). the excel file should open up and not display the open/save dialog.
    following is the code that i am using. i am not able to get it to work. getting an illegalstateexception and also i am getting all garbage diplayed in the browser. no excel. kindly help.
    <%@ page import="java.io.*" contentType="application/vnd.ms-excel"%>
    <%@ taglib uri="/WEB-INF/tlds/sapphire.tld" prefix="sapphire" %>
    <%@ taglib uri="/WEB-INF/tlds/c.tld" prefix="c" %>
    <%
    //response.reset();
    //response.setHeader("Pragma", "no-cache");
    //response.setHeader("Cache-Control", "no-cache");
    //response.setDateHeader("Expires", 0L);
    ServletOutputStream so = response.getOutputStream();
    String filename = "C:\\example1.xls";
    String mimetype = "application/vnd.ms-excel";
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    InputStream in = new BufferedInputStream(new FileInputStream(filename));
    byte bytebuff[] = new byte[500];
    for(int lengthread = 0; (lengthread = in.read(bytebuff)) != -1;){
    output.write(bytebuff, 0, lengthread);
    byte data[] = output.toByteArray();
    response.setContentType(mimetype);
    so.write(data);
    in.close();
    so.close();
    %>

    A JSP calls getWriter() by default.
    Every time you have a carriage return outside <% %> it gets written to the writer.
    The Illegal state exception would be because you are getting the outputStream after the writer.
    This is better done in a servlet, but can be done in a JSP, try it with code like this:
    <%@ page import="java.io.*" contentType="application/vnd.ms-excel"
    %><%@ taglib uri="/WEB-INF/tlds/sapphire.tld" prefix="sapphire"
    %><%@ taglib uri="/WEB-INF/tlds/c.tld" prefix="c"
    %><%
    %> Note that there is no text at all outside of the <% %> (not even carriage returns)
    Also, why are you writing to a ByteArrayOutputStream (ie into a memory byte array), and then writing the byte array to the servletoutputstream?
    Just put a buffer around the servlet outputstream and write directly to that.
    ServletOutputStream so = response.getOutputStream();
    BufferedOutputStream output = new ByteArrayOutputStream(so);
    ...

  • How to find out each Cell having Data or Not in Excel File by Using WDJ

    Hi Friends,
    I have one doubt on WDJ.
    I have to Upload Excel File. Click on Upload Button in Excel file Data will move to One Bapi. This is I was done. But my Requirement is if any empty Cell in Excel That File not uploaded it display one error message Please upload Correct Excel File
    How to find out each Cell having Data or Not in Excel File by Using WDJ. Please tell me.
    By Using this Code I have Upload Excel File
    InputStream text = null;
         int temp = 0;
         //wdComponentAPI.getMessageManager().reportSuccess("filePath Vijay:::");
         try
                   File file = new File(wdContext.currentContextElement().getResource().getResourceName().toString());     
    FileOutputStream op = new FileOutputStream(file);
                   if (wdContext.currentContextElement().getResource()!= null)
                          text = wdContext.currentContextElement().getResource().read(false);
                             while((temp=text.read())!= -1)
                                  op.write(temp);
                                  op.flush();
                                  op.close();
                                  path = file.getAbsolutePath();
                                  //wdComponentAPI.getMessageManager().reportSuccess("Path Name :::::"+path);
         catch(Exception ex)               
                   ex.printStackTrace();
    But my Requirement is If excel having any Empty Cell that excel file not uploaded.How to do this...
    Regards
    Vijay Kalluri

    Hi my friend
    I would like to share you some APACHE APi´s that i use when i have to read excel files in Web Dynpro.
    JAR = poi-3.2-FINAL-20081019.jar
    Some Example:
    POIFSFileSystem fs;
    HSSFWorkbook wb;
    HSSFSheet sheet;
    String myMexican_ValueFromExcelis = "";
    try {
             fs = new POIFSFileSystem(new FileInputStream();
             // and select the cell "y"
            cell = row.getCell( 0 );
            myMexican_ValueFromExcelis = cell.getCellValue();  
    }cach(Exception e){
    REgargds

  • Down excel file in managed bean, no response?

    Hi,
    I used JDev 11.1.2
    I want to download an excel file by click one button, and I want to implement this function in the managed bean, but after I click the button, no file download, and just refresh the page.
    JSP snippet code:
    <af:commandToolbarButton text="View Report" id="ctb1" actionListener="#{reportBean.viewReport}">
    Method of managed bean(not show exception process ):
    public void viewReport(ActionEvent actionEvent) {
    // some validation here
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    HttpServletResponse response = (HttpServletResponse)externalContext.getResponse();
    BufferedInputStream input = null;
    BufferedOutputStream output = null;
    String filePath = "c:/a.xls";
    File file = new File(filePath);
    try {
    input = new BufferedInputStream(new FileInputStream(file), 1024);
    response.reset();
    response.setHeader("Content-Disposition", "attachment; filename=\"" + filePath + "\"");
    response.setContentType("application/ms-excel");
    output = new BufferedOutputStream(response.getOutputStream(), 10240);
    byte[] buffer = new byte[10240];
    int length;
    while ((length = input.read(buffer)) > 0) {
    output.write(buffer, 0, length);
    output.flush();
    }catch(Exception e){
    } finally {
    //close output and input
    facesContext.responseComplete();
    BTW: I can implement the download function by using fileDownloadActionListener, but our requirement needs to validate some information before download(such as status validation, file existence), and I add those validation to fileDownloadActionListener method, but seems no useful.
    Any advices?
    Thanks,
    zeroxin

    Timo,
    I used the solution mentioned in your blog, and it really can enter into fileDownloadActionListener method, but still not display download file dialog, just seems no useful, I test it using Firefox4 and IE9, the same result.
    JSP snippet code:
    <af:commandToolbarButton text="View Report" id="ctb1"
    actionListener="#{reportBean.viewReport}"/>
    <af:commandToolbarButton text="Export..." id="ctb2" visible="false"
    binding="#{reportBean.exportReportButton}">
    <af:fileDownloadActionListener contentType="application/vnd.ms-excel" filename="Report.xls" method="#{reportBean.reportFileDownload}" />
    </af:commandToolbarButton>
    Bean method(Snippet code)
    private RichCommandToolbarButton exportReportButton;
    public void viewReport(ActionEvent actionEvent) {
    // validate code here
    ActionEvent ae = new ActionEvent(exportReportButton);
    ae.queue();
    public void reportFileDownload(FacesContext facesContext, java.io.OutputStream outputStream) throws Exception {
    DCIteratorBinding dciter = (DCIteratorBinding)getBindings().get("SReportView1Iterator");
    Object outputLoc = dciter.getCurrentRow().getAttribute("OutputLoc");
    BufferedInputStream input = null;
    try {
    input = new BufferedInputStream(new FileInputStream((String)outputLoc), 1024);
    byte[] buf = new byte[1024];
    int count=0;
    while ((count = input.read(buf)) >= 0) {
    outputStream.write(buf, 0, count);
    input.close();
    outputStream.flush();
    outputStream.close();
    } catch (Exception e) {
    e.printStackTrace();
    thanks,
    zeroxin

  • BO Live Office - Excel files no longer opening

    Hi all,
    I've been running into a problem and only encountered it when installing BO Live Office. On my old computer, I used to be able to click on an Excel file that was on my desktop, for example, and then Excel would automatically open up and open the file. Then when I downloaded Live Office, I was no longer able to do this. Now everytime I click on an Excel file (no matter where it is located), I keep getting an error. Excel opens, but it tells me "There was a problem sending the command to the program."
    At first I thought it was just my computer messing up and or something else was going wrong, but now I'm not so sure. I just recently got a new computer and I tried out opening an Excel file (from my desktop, for example) and it worked. Then I went and installed Live Office with the latest FixPack, etc. Once I installed it, it would no longer let me open an Excel File by clicking on the file. I keep getting the same error - "There was a problem sending the command to the program."
    On my old computer, I had Office 2003 w/Windows XP and now I have Office 2007 w/Windows 7. It doesn't seem to matter if I have the latest software or upgrades/fixpacks. This error still occurs. I've tried turning off/disabling the Live Office Plug-in, but this has not worked either. Has anyone run into this problem before? I'm not sure how to go about fixing it. Any help would be appreciated.
    Thank you,
    Charlette

    Hi,
    I also had the same issue (from couple of months) after we upgraded and it was very very frustating until I saw this post.
    Thanks a lot Tracy.
    I added "%1" at the end in the field labeled u2018Application used to perform action:u2019
    "......\Microsoft Office\Office12\EXCEL.EXE" "%1" /e
    The excel files are now opening. But there is also a message along with it. It says as below.
    >>>
    Windows cannot find '<excel file name goes here>'. Make sure you typed the name correctly, and then try again. To searcg for a file, click the Start button, and then click Search.
    >>>
    It's odd that the file is opening fine even though the above message shows up. This happens to every .XLS and .XLSX file. Atleast the file is opening now, which is great!
    I am not sure how to fix the warning message.
    Any help is appreciated.
    Thanks again.
    Edited by: Prapoorna Kolan on Aug 24, 2011 5:20 PM
    Edited by: Prapoorna Kolan on Aug 24, 2011 5:21 PM

  • IE 7 not displaying PDF files

    WinXP SP3 desktop
    Installed: Acrobat Reader 9 and Acrobat 6.0 Professional
    Up until recently, when an update from MS and adobe were installed, Internet Explorer 7 has been displaying PDF files when clicking on a link to the document. I do not know which company is at fault for compatibility here, but I would prefer to have IE7 read/save PDF docs. As it is now, an window pops up (no error number) saying "The Adobe Acrobat/Reader that is running can not be used to view PDF files in a Web Browser. Adobe Acrobat/Reader version 8 or 9 is required. Please exit and try again." I click the OK button then Acrobat 6.0 Pro loads and with no document showing. Simply turns on. I open any PDF file manually using either Reader 9 or Pro 6, but IE7 will only come up with above msg.
    Corrective actions attempted were:
    1) Reinstall Reader 9 on top of itself.
    2) In Pro 6, Edit | Preferences | Internet and deselected "Display PDF in browser, restarted program, went back to re-select it, restarted program.
    I did notice a new process running named: wisptis.exe
    The error message above sounds more like to me that the Pro is assigned the job to read downloaded PDF files, but with the Web Browser Option set to "Display PDF in browswer", I do not know why IE7 is not reading them.
    Thank you for your help in advance.
    Kay

    Try troubleshooting the Safari .plist file.
    Quit Safari.
    Open a Finder window. Select your Home Folder in the Sidebar on the left. It has a small house icon. Then open the Library folder then the Preferences folder.
    Move the com.apple.Safari.plist file from the Preferences folder to the Desktop.
    Launch Safari. See if that made a difference.
    Also, check Safari / Preferences - Extensions. Make sure it's not an Extension preventing PDF's from rendering.

  • How to view/open excel file in EBS

    Hi ,
    I have a requirement to open an excel file by clicking a link in EBS.
    Does anyone know how to do it, pls consider that i have a file named xyz.xls locally on a windows machine and i have to deploy it on EBS instance and view it by logging in.
    Just opening of that file using some link is sufficient

    just build a link to that file location on the server and send it back to the client
    MeTitus

  • Open an excel file from jsp

    Hi,
    I want to open an excel file on click of a link in the jsp.
    At present iam using href which i feel is not correct as it is not able to recognize the excel format and paints the entire screen with special characters.Can anyone please help me out.
    Thanks,

    In your server, there should be some way to tell the server the mime type of a file based on the file's extension. So, you tell the server for every file with the extension of .xls, it should use the mime type of application/vnd.ms-excel. Then, when the link is clicked on, the browser will receive the mime-type message of application/vnd.ms-excel and will open Excel to work with the file.
    Hope this helps,
    Ron

  • Problem while opening an excel file

    Hi
    I am trying to open an excel file by clicking a link where it goes to action class and then sets the content type to excel and I am opning it from there�but the strange thing is that a file download opens with open/save/cancel but in the same window but it is showing a warning in the dailog box(windows warning which comes as an exclamatory mark) saying "This type of file could harm your computer if it conatins malicious code" and on cliking open it shows a dialog saying "Could not open http://localhost:8080/context/myaction.do?fileName=3.xls" .Dont know why its trying to opne my action url rather than it should look for 3.xls in my folder
    Any clue on this would be helpful

    Hi,
    Try saving the file and then check if extension is xls. If you are not able to do anything (open, save), try to call the same application (file), from other machine, as sometimes browser gives the problem.
    If still problem occurs, then copy paste the code for setting the content type here.
    Best of luck,

  • Generate and disaply excel file as iview in ep6?

    Hello, everybody.
    I built a iView in EP5 that can generate and display excel file on the run-time. I used contecttype in httpservletresponse to set the content type to excel so the browser will see the data as excel.
    But it looks like the setcontenttype for httpservletresponse does not work anymore in EP6, does anybody know how to make the broswer "sees" the data as an excel file in EP6?
    I am using EP6 SP9

    Hi Gary,
    you definitely can set the content type if you call an AbstractPortalComponent and set all things within method doOnNodeReady (search for both terms on SDN forums, you'll find a heap of hints).
    In addition, I don't know if you create "real" Excel data or use the html trick. If you don't know the latter, see Export Portal data to Excel
    Hope it helps
    Detlev

  • Error message when clicking hyperlink in Excel file

    Hi all,
    I am working on SSRS 2012. In main report having hyperlink. When click this hyperlink in browser (IE 11 or Chrome), it open sub report correctly.
    But once i download the main report to Excel 2013 and click hyperlink, it can't open sub report.
    I am getting following error message in Excel file.
    Unable to open "http://...". Cannot download the information you requested.
    In SSRS 2005, it is working fine.
    How can i fix this issue in SSRS 2012?
    Thanks,
    Raja Shekhar Reddy

    Hi Raja,
    After testing the issue in my environment, I can reproduce the error message in Excel 2013. When the user who have no access to the report, it would display the error message that “Unable to open "http://...". Cannot download the information you requested.”
    when he click the hyperlink in Excel. So we can try to directly type the URL in browser to make sure the users have view permission to the report.
    Reference:
    Tutorial: Setting Permissions in Reporting Services
    Hope this helps.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How i will display an Excel file in java

    Hi,
    I have an excel File, Now i want to show it from java, i can do it by clicking an button. So when i will click a button then it will display that excel file thatt means it will be open. Is there anybody can help me?
    Please give me a sample. I need thid urgently. Please help me.
    With regards
    Bina

    look in your "jexcelapi_2_5_9" package, in order to print you have to have something that understands the file strucuture of the object you want to print--ie knows what an excel file is.

Maybe you are looking for