Java to Excel using JXLS

hi,
i am new to this forum... i am having an error in converstion to excel sheet.. i am using JXLS .. My sample program is here but i am getting a Class not found error..
package jexceldemo;
import java.io.*;
import org.jxls.exception.ParsePropertyException;
import org.jxls.transformer.XLSTransformer;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.impl.LogFactoryImpl;
import org.apache.commons.logging.LogConfigurationException;
import org.jxls.transformer.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class excel {
public excel() {
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
private static String templateFileName = "C:\\temp1\\grouping.xls";
private static String destFileName = "C:\\temp1\\grouping_output.xls";
private static Department mobjDepartment =null;
public boolean addData(String pstrDepData, String[] pstrChiefData, String[][] palEmpData){
boolean mblnResStatus=false;
Employee mobjEmployees = null;
Employee mobjChief=null;
String name;
int age;
Double payment;
Double bonus;
try{
mobjDepartment = new Department(pstrDepData);
mobjChief=new Employee(pstrChiefData[0],Integer.parseInt(pstrChiefData[1]),Double.valueOf(pstrChiefData[2]),Double.valueOf(pstrChiefData[3]));
mobjDepartment.setChief(mobjChief);
System.out.println("Name\tAge\tPayment\tBonus");
System.out.println("------------------------------");
for(int inEmp=0;inEmp<palEmpData.length;inEmp++){
name = palEmpData[inEmp][0].toString();
age = Integer.parseInt(palEmpData[inEmp][1].toString());
payment = Double.valueOf(palEmpData[inEmp][2].toString());
bonus = Double.valueOf(palEmpData[inEmp][3].toString());
mobjEmployees = new Employee(name, age, payment, bonus);
mobjDepartment.addEmployee(mobjEmployees);
System.out.println(name+"\t"+age+"\t"+payment+"\t"+bonus);
System.out.println("------------------------------");
catch(Exception mobjEx){
System.out.println("Error"+mobjEx.getMessage());
return mblnResStatus;
public static void main(String[] args) throws IOException, ParsePropertyException {
excel ex=new excel();
if (args.length >= 2) {
templateFileName = args[0];
destFileName = args[1];
String[] mstrobjChief={"Pravin","23","2500","1000"};
String[][] mstrobjEmp=new String[5][4];
for(int inEmpinfo=0;inEmpinfo<5;inEmpinfo++){
mstrobjEmp[inEmpinfo][0]="Name"+inEmpinfo;
mstrobjEmp[inEmpinfo][1]=""+inEmpinfo;
mstrobjEmp[inEmpinfo][2]=""+inEmpinfo;
mstrobjEmp[inEmpinfo][3]=""+inEmpinfo;
ex.addData("IT",mstrobjChief,mstrobjEmp);
Map beans = new HashMap();
beans.put("departments", mobjDepartment);
XLSTransformer transformer = new XLSTransformer();
transformer.transformXLS(templateFileName, beans, destFileName);
private void jbInit() throws Exception {
The error i am getting is
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
     at org.jxls.transformer.XLSTransformer.<init>(XLSTransformer.java:30)
     at jexceldemo.excel.main(excel.java:93)
Exception in thread "main"
Eployee and Department are bean classes..

Hi,
I am trying StyleRowProcessor to apply some styles to particular cell. In JXLS examples, I did not get this lines.
String styleCellLabel = "customRow";
if( namedCells.containsKey( styleCellLabel ) ){
Cell customCell = (Cell) namedCells.get( styleCellLabel );
for (int i = 0; i < row.getCells().size(); i++) {
Cell cell = (Cell) row.getCells().get(0);
HSSFCell hssfCell = cell.getHssfCell();
if( hssfCell!=null ){
copyStyle( row.getSheet().getHssfWorkbook(), customCell.getHssfCell(), hssfCell );
What is this customRow, From where do we pass or set this?

Similar Messages

  • Help Needed in creating dropdown menu in excel using JXL

    Hi,
    I am trying to create dropdown menu in using JXL.
    The Code:
    private void createRequiredRows(WritableSheet writableSheet, List unallowCodeList,int rowCount
                   , int startRowNo,int colCount) throws WriteException {
    Label unallowCode = null;
              WritableFont noBoldFont = new WritableFont(WritableFont.ARIAL, 8,WritableFont.NO_BOLD);
              WritableCellFormat dropDownCellFormat = new WritableCellFormat(noBoldFont,new NumberFormat("000"));
              dropDownCellFormat.setAlignment(Alignment.RIGHT);
              WritableCellFeatures writableCellFeature = new WritableCellFeatures();
              writableCellFeature.setDataValidationList(unallowCodeList);
              for (int rowNo = startRowNo; rowNo < startRowNo + rowCount; rowNo++) {
                   unallowCode = new Label(colCount, rowNo, "Select",dropDownCellFormat);
                   unallowCode.setCellFeatures(writableCellFeature);
                   writableSheet.addCell(unallowCode);
    it creates a drop down in the Excel.
    But writableCellFeature.setDataValidationList(unallowCodeList); has a limitation of characters .So the dropdown menu gets truncated when it exceeds the limitation.
    Can anyone help me in creating dropdown menu in excel without any limitation using JXL..
    Thanks,
    Bisin

    Hi,
    I dont know the solution for this, but heres a work arround
    //create new label some where else in the excel sheet as shown below
    Label lblcmbdata;
    for(int i=0; i<1000; i++)
                 lblcmbdata = new Label(75, i, (i+1)+" satish", format);
                 sheet1.addCell(lblcmbdata);
    }//set the validation range as shown below
    writableCellFeature.setDataValidationRange(75,0,75,1000);
    Label cmb = null;
    cmb = new Label(0, 1, "Select",format);
    cmb.setCellFeatures(writableCellFeature);
    sheet.addCell(cmb);this will create a combo list with 1000 values
    also you can keep the data to be populated in the different sheet in same workbook by creating a named range as below
    workbook.addNameArea("cmbdata", sheet1, 0, 0, 0, 1000);
    // then fill the data in sheet1
    Label lblcmbdata;
    for(int i=0; i<1000; i++)
                    lblcmbdata = new Label(0, i, (i+1)+" satish", format);
                    sheet1.addCell(lblcmbdata);
    //set the validation named range as below
    writableCellFeature.setDataValidationRange("cmbdata");
    Label cmb = null;
    cmb = new Label(0, 1, "Select",format);
    cmb.setCellFeatures(writableCellFeature);
    sheet.addCell(cmb);Thanks and Regards
    Satish

  • Upload to Excel using Java Bean

    Hi
    My requirement is that to upload the data to an excel sheet from a JTable(JTable is actually a java bean which gets its input from forms) and the user need to be given either to view the excel/save the excel/print the excel in any of the networked printers.
    Please cud someone help me with their inputs.
    Thanks again
    Deepa

    can you send me your code bean and form?
    I have example that i can send you to export to excel using webutil and OLE object.

  • How to create autofilter in excel page using jxl api?

    Hi Friends,
    I am using jxl api for excel generation. Its no problem
    but i need to set auto filter options. I am search in this API package but i can't find it.
    Any one know how to create autofilter in excel page using jxl api?.
    Please ..... Its urgent.... ...
    Thanks

    Hi,
    Please mail me on [email protected] if u will find any solutions, i will do the same if i will find any...
    Thank u in advance,

  • Using jxl.jar in Java Web Dynpro using NWDS 7.0.09

    Hi ,
    I have a requiremnt to read excel file and I am trying to use jxl.jar for the same but I am facing issues which using it as External Library DC.During executing,I am getting NoClassFoundException.Please help .

    Hi
    Only one thing u missed that instead of Publishing as file you have to publish it as archive.
    Further u can check
    1. Publish as archive.for both compilation and assembly.
    2. Each changes require Build of the external library dc also.Build it and then run
    Best Regards
    Satish kumar

  • How to add dropdown in excel using java?

    First of all sorry for creating new topic... i searched for it but i couldn't get it...
    Guys do you have any idea on how to add drop down in excel using Andy Khan's JExcel API? Or is there any other way?

    Sounds like a question for Andy Khan or the JExcel forum.

  • Using jxl.jar in VJ++

    Hello,
    This is the first time i am writting to a forum. I have a problem. Can any one plz help.
    I am using VJ++ to read and write Excel Files. Is there a good API which can help me? After searcing, i found jxl.jar. but when i use it with VJ++, i get the following error.
    java.lang.NoClassDefFoundError
    can u plz help me?
    Here is the code:
    package com.netech.rf.lsr;
    import java.io.File;
    import jxl.write.WriteException;
    import jxl.Workbook;
    import jxl.write.WritableWorkbook;
    import jxl.write.WritableSheet;
    public class testing
         public String writeLSR(String fileName) throws WriteException, Exception
              WritableWorkbook LSRbook = Workbook.createWorkbook(new File(fileName));
              WritableSheet lsr = LSRbook.createSheet("LSR",0);
              //writting and closing the excel sheet
              LSRbook.write();
              LSRbook.close();
              String msg = "successfully written";          
         return msg;
         public static void main(String args[])
              try{                    
                   testing lsrrecord = new testing();
                   String msg = lsrrecord.writeLSR("LSRRECORD.XLS");
                   System.out.println(msg);          
              catch(WriteException e)
                   System.out.println("WriteException: " + e.getMessage());
              catch(Exception ex)
                   System.out.println("Exception: " + ex.getMessage());
    But when try to run, it works fine
    E:\TEST_PROJECTS\ExcelTest1>java com.netech.rf.lsr.testing
    successfully written
    But when i create a executable and run the same program, it gives me error:
    E:\TEST_PROJECTS\ExcelTest1>excelTest1.exe
    java.lang.NoClassDefFoundError
    Here is my classpath:
    E:\TEST_PROJECTS\ExcelTest1>echo %classpath%
    C:\WINNT\DnClasses\jxl.jar;;;.;.;.;.;.;.;.;.;.;C:\WINNT\DnClasses\rmi.zip;C:\WINNT\DnClasses\rt.jar;C:\WINNT\DnClasses\activation.jar;C:\WINNT\DnClasses\jndi.jar;C:\WINNT\DnClasses\mail.jar;C:\WINNT\DnClasses\pop3.jar;C:\WINNT\DnClasses\providerutil.jar;C:\WINNT\DnClasses\ldap.jar;C:\WINNT\DnClasses\classes12.zip;C:\NETECH\RFServer\com.jar
    PLEASE ADVICE

    Crosspost!

  • Error while running WDJ application using jxl.jar

    Hi Experts,
    I am using jxl.jar in my webdynpro java application in CE7.2. I added jxl.jar in java build path and place the jar file in lib directory of webdynpro DC. It shows error in development configuration perspective while building, then i created another DC of type ExternalLibrary and added jxl.jar in libraries folder, then i right click on that jar and published as archive. Then in Development configuration perspective i added ExternalLibrary project to my webdynpro DC, it doen't shows error while building.
    I deployed successfully, when i run the application, it shows the following error. Is there any fault in adding external jar to mt DC? i can't understand where the problem is?
    Error:
    java.lang.ClassNotFoundException: jxl.Workbook -
    Loader Info -
    ClassLoader name: [com.drl.bomrecipe/bomrecipe] Loader hash code: 30a86ee9 Living status: alive Direct parent loaders: [system:Frame] [interface:webservices] [interface:cross] [interface:security] [interface:transactionext] [library:webservices_lib] [library:opensql] [library:jms] [library:ejb20] [service:p4] [service:ejb] [service:servlet_jsp] [sap.com/tcwdapi] [library:tcblexceptionlib] [library:tcblloggingapi] Resources: E:\usr\sap\CE7\J00\j2ee\cluster\apps\com.drl.bomrecipe\bomrecipe\servlet_jsp\webdynpro\resources\com.drl.bomrecipe\bomrecipe\root\WEB-INF\lib\com.drl.bomrecipe~bomrecipe.jar -
        at com.sap.engine.boot.loader.MultiParentClassLoader.loadClass(MultiParentClassLoader.java:272)
        at com.sap.engine.boot.loader.MultiParentClassLoader.loadClass(MultiParentClassLoader.java:241)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:367)
    help me please, thanks in advance
    Regards,
    Pradeep Kumar G

    Hi Pradeep,
    Have you created both compilation and assembly public parts for your Ext Lib, and have you added them both to your Used DC's list?
    Also remember, since you are using an assembly public part, the 'Create Archive' and 'Deploy new archive and run' should not be used!
    Use the DC Build and DC Deploy instead.
    Hope this helps!
    Robin van het Hof

  • Error using JXL api in a KM Report

    Hi Expert,
    My report have to use JXL api. I have already a DC containing libraries, including JXL 2.6.2.
    I declare my DC in Used DC of my report, but each time I launch it it throws me this error :
    "error executing: /reporting/reports/Content Management/Tools/rise_metrics/1237311667619.xml(com.sapportals.wcm.service.reporting.ReportInput@356422d2) - java.lang.NoClassDefFoundError: jxl/format/CellFormat at com.ctsao.project.rise.metrics.RISEMetrics.execute(RISEMetrics.java:460) at com.sapportals.wcm.repository.manager.reporting.monitor.ReportComponent$ReportWrapper.execute(ReportComponent.java:160) at com.sapportals.wcm.service.reporting.scheduler.ReportScheduler$Runner.run(ReportScheduler.java:220)"
    Is it possible to use this API in a report or there is some restriction ?
    Thanks in advance for your help,
    Jean-Edouard Nicolet.

    Hi,
    Try to include the jxl.jar file inside your private/lib folder of project and run as a workaround.
    Regards
    Baby

  • I have a scenario. Import IDOC into PI and PI transform IDOC to Excel. Using mail adapter attach that Excel using pi and send to customer. Can you please help me on the same?

    HI Experts,
    I have a scenario. Import IDOC into PI and PI transform IDOC to Excel. Using mail adapter attach that Excel using pi and send to vendor. Can you please help me on the same?
    Thanks
    SaiSreevastav

    Hi Sai,
    you can use XSLT or java mapping or adapter module to convert IDOC xml to XLS. Please refer the below blog
    Convert incoming XML to Excel or Excel XML – Part 1 - XSLT Way
    Convert incoming XML to Excel Sheet Part 2 – Adapter Module way
    Convert incoming XML to Excel Sheet
    then after converting to Excel, you can use the payloadswap bean in mail adapter
    XI: Sender mail adapter - PayloadSwapBean - Step by step
    regards,
    Harish

  • Extract data from Java to Excel

    Apologies for my ignorance in this field but is it possible to extract data from a Java based application (stock charts and the like) directly into Excel? If so could someone please contact me and explain the process in very simple terms as i have no idea how Java works :o)
    Many thanks.
    Gilsey

    Actually I should qualify my "Yes" answer. It is possible for a Java application to output data to Excel (using Jakarta POI for example). Whether it is possible to persuade an existing Java application to do that depends on the application. If it has been programmed to do it, then yes. Or if it has an underlying database where it stores its data, and you have access to that database, it might be possible to extract data from the database into Excel. Otherwise the programming of the application would have to be changed.

  • Exporting into Excel Using the Dynpro Binary Cache is not working on NW04s

    Hello,
    I am using excel data export using the
    "Exporting Context Data into Excel Using the Web Dynpro Binary Cache" guide at
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/edc2f3c2-0401-0010-8898-acd5b6a94353">this link</a>.
    The tutorial is working on NW04 but when I use it on NW04s I receive errors for the StringBuffer object:
    java.lang.NoSuchMethodError: java.lang.StringBuffer.append(Ljava/lang/String;)Ljava/lang/AbstractStringBuilder;
    Any ideas?

    Hallo Roy,
    I have created an updated/enhanced version of this tutorial running on NW 7.0. The new solution allows to open the exported Excel File instantly without opening a popup window befor:
    See <a href="https://wiki.sdn.sap.com/wiki/x/0mQ">Exporting Table Data Using On-Demand Streams - SAP NetWeaver 7.0</a>.
    <b>NOTE:</b>
    Use <b>LinkedHashMap</b> instead of <i>HashMap</i>
      private Map getProductColumnInfos() {
        Map columnInfosMap = new LinkedHashMap();
        columnInfosMap.put(IPrivateTableCompBasketView.IProductsElement.QUANTITY, "Quantity");
        columnInfosMap.put(IPrivateTableCompBasketView.IProductsElement.ARTICLE, "Article");
        columnInfosMap.put(IPrivateTableCompBasketView.IProductsElement.COLOR, "Color");
        columnInfosMap.put(IPrivateTableCompBasketView.IProductsElement.PRICE, "Price in EURO");
        columnInfosMap.put(
          IPrivateTableCompBasketView.IProductsElement.TOTAL__PER__ARTICLE,
          "Total Per Article In Euro");
        return columnInfosMap;
    This keeps the order of key-displaytext-pairs passed by the client (table component) to the service (excel export component) stable.
    Regards, Bertram

  • Problem while writing data on xls file using jxl API

    Hi,
    I am getting problem while writing data on excel file using jxl api.
    When i write data on file and all handles associated to the file are closed, file size increases but when i open the file nothing is written in it and when file is closed manually from excel window, file size decreased to its original that was before writing data.
    here is code:
              FileOutputStream os = new FileOutputStream(this.dirPath + this.fileName, true);
              WritableWorkbook this.workbook = Workbook.createWorkbook(os);
    after writing data following handler are closed:
    this.os.flush();
                        this.workbook.write();
                        this.workbook.close();
                        this.os.close();
                        this.os = null;
    can any body help me.
    Thanks in advance

    Err, I did help you. I did understand your problem; and I solved it for you. What was missing was that you apparently made no effort to understand what you were being told. Or even consider it. You just argued about it, as though you were the one with the solution, instead of the one whose code didn't work.
    And the other thing that was missing was the part where you said 'thank you' to me for solving your problem. Somewhat more appropriate than biting the hand that fed you, frankly. I do this for nothing, on my own gas, and it's extremely irritating when people keep asking about problems I have already solved for them. I am entitled to discourage that. It's part of making them more efficient actually.
    But it happens often enough that it also makes me think I'm just wasting my time. Probably I am.

  • Controlling the data formatting in excel using jsp.

    Hi,
    How to controlling the data formatting in excel using jsp with out using external jar files such as "jexcel" and "POI". And one more limitation is that it should be compatible with java 1.2.1

    dineshniot wrote:
    Hi - Is there any possibility to automatically display the chart for the logged datas using write to measurement file or write to data file? Please let me know as soon as possible.
    Thanks and Regards,
    Dinesh
    As an aside, "data" is already a plural.  The singular is "datum."
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

  • Chinese csv file export to excel using POI

    Dear all,
    I would like to read the csv chinese data to excel using POI in java but the character in excel is corrupted. How can I solve it? Please help me. Thank you!
    Regards,
    kzyo

    Use the correct encoding for the reading and writing streams.

Maybe you are looking for

  • How to get Spam folder in Apple Mail?

    I received some important emails in my spam folders when I checked them with Safari, but Apple mail does not have them in Inbox or Junk folder. How to get Spam folder in Apple Mail?

  • Cryptographic error on a SharePoint 2013 Provider Hosted App

    Below mentioned is the error: System.TypeInitializationException: The type initializer for 'ABABABA.TokenHelper' threw an exception. ---> System.Security.Cryptography.CryptographicException: Access denied. at System.Security.Cryptography.Cryptographi

  • Printng page using a href on server location

    Hello GURUS, I am printing a document on client machine . document is located on server. in my jsp page I have coded javascript prt.setAttribute("href", altdoc);          printWindow();is used for printing. This code workes properly when i run it on

  • Problems with Wait inside Switch inside While

    Hi! I have implemented a process that does something like this (BPEL 10.1.3.3): 1. reads some data and sets some variables 2. has a While activity that tries for 5 times to post some xml message to specified URL 3. if it doesn't succeed than set some

  • Archives from PRD to DR

    Hi All, Our SAP System: ECC 6.0 Windows 2003 Oracle DB 10.2.0.4 We started our DR 1 month before and started patching it. as DR is UP and all Patches are successfully applied. We want to shift our users from PRD to DR and want to patch the PRD. How c