Results 1 to 3 of 3
  1. #1
    slan is offline Member
    Join Date
    Jan 2011
    Posts
    1
    Rep Power
    0

    Default Problem with Excel

    Java Code:
    package writeexcel;
    import java.io.*;
    import jxl.*;
    import java.util.*;
    import jxl.Workbook;
    import jxl.write.DateFormat;
    import jxl.write.Number;
    
    import jxl.write.*;
    import java.text.SimpleDateFormat;
    
    class  Main
    {
      public static void main(String[] args)
      {
        try
        {
          String filename = "D://input.xls";
          WorkbookSettings ws = new WorkbookSettings();
          ws.setLocale(new Locale("en", "EN"));
          WritableWorkbook workbook =
            Workbook.createWorkbook(new File(filename), ws);
          WritableSheet s = workbook.createSheet("Sheet1", 0);
          WritableSheet s1 = workbook.createSheet("Sheet1", 0);
          writeDataSheet(s);
          writeImageSheet(s1);
          workbook.write();
          workbook.close();
        }
        catch (IOException e)
        {
          e.printStackTrace();
        }
        catch (WriteException e)
        {
          e.printStackTrace();
        }
      }
    
      private static void writeDataSheet(WritableSheet s)
        throws WriteException
      {
    
        /* Format the Font */
        WritableFont wf = new WritableFont(WritableFont.ARIAL,
          10, WritableFont.BOLD);
        WritableCellFormat cf = new WritableCellFormat(wf);
        cf.setWrap(true);
    
        /* Creates Label and writes date to one cell of sheet*/
        Label l = new Label(0,0,"Date",cf);
        s.addCell(l);
        WritableCellFormat cf1 =
          new WritableCellFormat(DateFormats.FORMAT9);
    
        DateTime dt =
          new DateTime(0,1,new Date(), cf1, DateTime.GMT);
    
        s.addCell(dt);
    
        /* Creates Label and writes float number to one cell of sheet*/
        l = new Label(2,0,"Float", cf);
        s.addCell(l);
        WritableCellFormat cf2 = new WritableCellFormat(NumberFormats.FLOAT);
        Number n = new Number(2,1,3.1415926535,cf2);
        s.addCell(n);
    
        n = new Number(2,2,-3.1415926535, cf2);
        s.addCell(n);
    
        /* Creates Label and writes float number upto 3
           decimal to one cell of sheet */
        l = new Label(3,0,"3dps",cf);
        s.addCell(l);
        NumberFormat dp3 = new NumberFormat("#.###");
        WritableCellFormat dp3cell = new WritableCellFormat(dp3);
        n = new Number(3,1,3.1415926535,dp3cell);
        s.addCell(n);
    
        /* Creates Label and adds 2 cells of sheet*/
        l = new Label(4, 0, "Add 2 cells",cf);
        s.addCell(l);
        n = new Number(4,1,10);
        s.addCell(n);
        n = new Number(4,2,16);
        s.addCell(n);
        Formula f = new Formula(4,3, "E1+E2");
        s.addCell(f);
    
        /* Creates Label and multipies value of one cell of sheet by 2*/
        l = new Label(5,0, "Multipy by 2",cf);
        s.addCell(l);
        n = new Number(5,1,10);
        s.addCell(n);
        f = new Formula(5,2, "F1 * 3");
        s.addCell(f);
    
        /* Creates Label and divide value of one cell of sheet by 2.5 */
        l = new Label(6,0, "Divide",cf);
        s.addCell(l);
        n = new Number(6,1, 12);
        s.addCell(n);
        f = new Formula(6,2, "F1/2.5");
        s.addCell(f);
      }
    
      private static void writeImageSheet(WritableSheet s)
        throws WriteException
      {
        /* Creates Label and writes image to one cell of sheet*/
        Label l = new Label(0, 0, "Image");
        s.addCell(l);
        WritableImage wi = new WritableImage(0, 3, 5, 7, new File("image.png"));
        s.addImage(wi);
    
        /* Creates Label and writes hyperlink to one cell of sheet*/
        l = new Label(0,15, "HYPERLINK");
        s.addCell(l);
        Formula f = new Formula(1, 15,
          "HYPERLINK(\"http://www.andykhan.com/jexcelapi\", "+
          "\"JExcelApi Home Page\")");
        s.addCell(f);
    
        }
    }
    After start this example alert exceptions:"Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name functions, locale en_EN
    at java.util.ResourceBundle.throwMissingResourceExcep tion(ResourceBundle.java:1427)
    at java.util.ResourceBundle.getBundleImpl(ResourceBun dle.java:1250)
    at java.util.ResourceBundle.getBundle(ResourceBundle. java:777)
    at jxl.biff.formula.FunctionNames.<init>(FunctionName s.java:59)
    at jxl.WorkbookSettings.getFunctionNames(WorkbookSett ings.java:579)
    at jxl.biff.formula.Function.getFunction(Function.jav a:162)
    at jxl.biff.formula.StringFunction.getFunction(String Function.java:67)
    at jxl.biff.formula.StringFormulaParser.handleFunctio n(StringFormulaParser.java:352)
    at jxl.biff.formula.StringFormulaParser.parseCurrent( StringFormulaParser.java:144)
    at jxl.biff.formula.StringFormulaParser.parse(StringF ormulaParser.java:113)
    at jxl.biff.formula.FormulaParser.parse(FormulaParser .java:161)
    at jxl.write.biff.FormulaRecord.initialize(FormulaRec ord.java:160)
    at jxl.write.biff.FormulaRecord.setCellDetails(Formul aRecord.java:243)
    at jxl.write.biff.WritableSheetImpl.addCell(WritableS heetImpl.java:1199)
    at writeexcel.Main.writeImageSheet(Main.java:127)
    at writeexcel.Main.main(Main.java:31)
    Java Result: 1".
    Can you help me?? I changed local on another but example did not work...

  2. #2
    Armadillo is offline Member
    Join Date
    Jul 2010
    Posts
    15
    Rep Power
    0

    Default

    I dont know anything about jxl but what the error indicates is that you are missing the locale resource file. This is a textfile containg key-value pairs. Have you tried stepping through your code hereabouts:

    at java.util.ResourceBundle.getBundleImpl(ResourceBun dle.java:1250)
    at java.util.ResourceBundle.getBundle(ResourceBundle. java:777)
    at jxl.biff.formula.FunctionNames.<init>(FunctionName s.java:59)

    To find the name of the missing file?

  3. #3
    democom is offline Member
    Join Date
    Mar 2011
    Posts
    1
    Rep Power
    0

    Cool Solution

    Hello,

    I had the same problem.
    The solution is to add a file functions.properties at the root of your sources.
    Below its contents:

    count = COUNT
    isna = ISNA
    iserror = ISERROR
    sum = SUM
    average = AVERAGE
    min = MIN
    max = MAX
    row = ROW
    column = COLUMN
    na = NA
    npv = NPV
    stdev = STDEV
    dollar = DOLLAR
    fixed = FIXED
    sin = SIN
    cos = COS
    tan = TAN
    atan = ATAN
    pi = PI
    sqrt = SQRT
    exp = EXP
    ln = LN
    log10 = LOG10
    abs = ABS
    int = INT
    sign = SIGN
    round = ROUND
    lookup = LOOKUP
    index = INDEX
    rept = REPT
    mid = MID
    len = LEN
    value = VALUE
    true = TRUE
    false = FALSE
    and = AND
    or = OR
    not = NOT
    mod = MOD
    dcount = DCOUNT
    dsum = DSUM
    daverage = DAVERAGE
    dmin = DMIN
    dmax = DMAX
    dstdev = DSTDEV
    var = VAR
    dvar = DVAR
    text = TEXT
    linest = LINEST
    trend = TREND
    logest = LOGEST
    growth = GROWTH
    pv = PV
    fv = FV
    nper = NPER
    pmt = PMT
    rate = RATE
    rand = RAND
    match = MATCH
    date = DATE
    time = TIME
    day = DAY
    month = MONTH
    year = YEAR
    weekday = WEEKDAY
    hour = HOUR
    minute = MINUTE
    second = SECOND
    now = NOW
    areas = AREAS
    rows = ROWS
    columns = COLUMNS
    offset = OFFSET
    search = SEARCH
    transpose = TRANSPOSE
    error = ERROR
    type = TYPE
    atan2 = ATAN2
    asin = ASIN
    acos = ACOS
    choose = CHOOSE
    hlookup = HLOOKUP
    vlookup = VLOOKUP
    isref = ISREF
    log = LOG
    char = CHAR
    lower = LOWER
    upper = UPPER
    proper = PROPER
    left = LEFT
    right = RIGHT
    exact = EXACT
    trim = TRIM
    replace = REPLACE
    substitute = SUBSTITUTE
    code = CODE
    find = FIND
    cell = CELL
    iserr = ISERR
    istext = ISTEXT
    isnumber = ISNUMBER
    isblank = ISBLANK
    t = T
    n = N
    datevalue = DATEVALUE
    timevalue = TIMEVALUE
    sln = SLN
    syd = SYD
    ddb = DDB
    indirect = INDIRECT
    clean = CLEAN
    mdeterm = MDETERM
    minverse = MINVERSE
    mmult = MMULT
    ipmt = IPMT
    ppmt = PPMT
    counta = COUNTA
    product = PRODUCT
    fact = FACT
    dproduct = DPRODUCT
    isnontext = ISNONTEXT
    stdevp = STDEVP
    varp = VARP
    dstdevp = DSTDEVP
    dvarp = DVARP
    trunc = TRUNC
    islogical = ISLOGICAL
    dcounta = DCOUNTA
    findb = FINDB
    searchb = SEARCHB
    replaceb = REPLACEB
    leftb = LEFTB
    rightb = RIGHTB
    midb = MIDB
    lenb = LENB
    roundup = ROUNDUP
    rounddown = ROUNDDOWN
    rank = RANK
    address = ADDRESS
    days360 = AYS360
    today = ODAY
    vdb = VDB
    median = MEDIAN
    sumproduct = SUMPRODUCT
    sinh = SINH
    cosh = COSH
    tanh = TANH
    asinh = ASINH
    acosh = ACOSH
    atanh = ATANH
    info = INFO
    avedev = AVEDEV
    betadist = BETADIST
    gammaln = GAMMALN
    betainv = BETAINV
    binomdist = BINOMDIST
    chidist = CHIDIST
    chiinv = CHIINV
    combin = COMBIN
    confidence = CONFIDENCE
    critbinom = CRITBINOM
    even = EVEN
    expondist = EXPONDIST
    fdist = FDIST
    finv = FINV
    fisher = FISHER
    fisherinv = FISHERINV
    floor = FLOOR
    gammadist = GAMMADIST
    gammainv = GAMMAINV
    ceiling = CEILING
    hypgeomdist = HYPGEOMDIST
    lognormdist = LOGNORMDIST
    loginv = LOGINV
    negbinomdist = NEGBINOMDIST
    normdist = NORMDIST
    normsdist = NORMSDIST
    norminv = NORMINV
    normsinv = NORMSINV
    standardize = STANDARDIZE
    odd = ODD
    permut = PERMUT
    poisson = POISSON
    tdist = TDIST
    weibull = WEIBULL
    sumxmy2 = SUMXMY2
    sumx2my2 = SUMX2MY2
    sumx2py2 = SUMX2PY2
    chitest = CHITEST
    correl = CORREL
    covar = COVAR
    forecast = FORECAST
    ftest = FTEST
    intercept = INTERCEPT
    pearson = PEARSON
    rsq = RSQ
    steyx = STEYX
    slope = SLOPE
    ttest = TTEST
    prob = PROB
    devsq = DEVSQ
    geomean = GEOMEAN
    harmean = HARMEAN
    sumsq = SUMSQ
    kurt = KURT
    skew = SKEW
    ztest = ZTEST
    large = LARGE
    small = SMALL
    quartile = QUARTILE
    percentile = PERCENTILE
    percentrank = PERCENTRANK
    mode = MODE
    trimmean = TRIMMEAN
    tinv = TINV
    concatenate = CONCATENATE
    power = POWER
    radians = RADIANS
    degrees = DEGREES
    subtotal = SUBTOTAL
    sumif = SUMIF
    countif = COUNTIF
    countblank = COUNTBLANK
    hyperlink = HYPERLINK
    averagea = AVERAGEA
    maxa = MAXA
    mina = MINA
    stdevpa = STDEVPA
    varpa = VARPA
    stdeva = STDEVA
    vara = VARA
    if = IF

    PS: Sorry for my English I'm French

Similar Threads

  1. JSP To EXCEL
    By sureshsri1981 in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 09-24-2009, 10:12 PM
  2. Replies: 5
    Last Post: 08-21-2009, 11:03 AM
  3. Problem in Export to Excel using Jexcel api
    By Padmalatha in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 11-19-2008, 08:09 AM
  4. Problem with Excel
    By a_gomathi in forum Forum Lobby
    Replies: 7
    Last Post: 05-30-2008, 07:53 AM
  5. jsp excel
    By lak in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 03-29-2008, 10:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •