Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 11
  1. #1
    Utente di HTML.it
    Registrato dal
    Sep 2004
    Messaggi
    13

    [Java] elaborazioni Foglio Excel


    Ciao a tutti, buon 2005
    Ho bisogno di prendere il valore di una cella dove ho scritto una formula.

    Es:
    f = new Formula(6,17, "Foglio2!N4);
    foglio1.addCell(f);

    e fin qui tutto OK.

    ma se voglio fare un (tipo) getValue per prendere l'importo che è nella cella come si fa???????????

    Grazie Very

  2. #2
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    che librerie stai usando?
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  3. #3
    Utente di HTML.it
    Registrato dal
    Sep 2004
    Messaggi
    13

    Java - Excel

    Sto usando le import del package jxl:

    import jxl.write.Formula;

    Bye Very

  4. #4
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  5. #5
    Utente di HTML.it
    Registrato dal
    Sep 2004
    Messaggi
    13
    non mi aiuta

  6. #6
    Moderatore di Programmazione L'avatar di LeleFT
    Registrato dal
    Jun 2003
    Messaggi
    17,320
    Allora non hai letto nemmeno una riga del tutorial che Andrea1979
    ti ha linkato... il primissimo link (Introduction) ti riporta esattamente alle righe di codice di cui hai bisogno:

    (supponendo che in A1 ci sia la seguente formula: =SOMMA(A2:A3), e che in A2 e A3 siano presenti i valori 5 e 6)
    codice:
    import java.io.File; 
    import jxl.*; 
    
    ... 
    
    Workbook workbook = Workbook.getWorkbook(new File("myfile.xls")); 
    
    Cell a1 = sheet.getCell(0,0);  // 0,0: COLONNA A, RIGA 1
    
    System.out.println( a1.getContents() );
    questo codice stampa esattamente il valore 11.


    Ciao.
    "Perchè spendere anche solo 5 dollari per un S.O., quando posso averne uno gratis e spendere quei 5 dollari per 5 bottiglie di birra?" [Jon "maddog" Hall]
    Fatti non foste a viver come bruti, ma per seguir virtute e canoscenza

  7. #7
    Utente di HTML.it
    Registrato dal
    Sep 2004
    Messaggi
    13
    Già ho provato e non mi restituisce la somma ma la formula


    n = new Number(0,0, 12);
    s4.addCell(n);

    n = new Number(0,1, 15);
    s4.addCell(n);

    //Qui l'ho scritta
    form = new Formula(3,3,"SUM(A1:A2)");
    s4.addCell(form);

    // QUi voglio leggere il valore
    Cell a1 = s4.getCell(3,3);

    System.out.println("VALUE -->"+a1.getContents() );

    Il risultato è VALUE -->SUM(A1:A2)

    Allora??????????
    Cosa sbaglio?????
    Non e che forse non posso leggere un valore quando sto scrivendo un foglio????????
    BOOOO!!!!!!!!!!

  8. #8
    Moderatore di Programmazione L'avatar di LeleFT
    Registrato dal
    Jun 2003
    Messaggi
    17,320
    Credo che sia un problema delle API... a me non lascia nemmeno scrivere una formula che mi dà EmptyStackException...


    Ciao.
    "Perchè spendere anche solo 5 dollari per un S.O., quando posso averne uno gratis e spendere quei 5 dollari per 5 bottiglie di birra?" [Jon "maddog" Hall]
    Fatti non foste a viver come bruti, ma per seguir virtute e canoscenza

  9. #9
    Utente di HTML.it
    Registrato dal
    Sep 2004
    Messaggi
    13
    grazie lo stesso

    Bye Bye very

  10. #10

    Api

    Leggendo la documentazione dice cheil metodo: getContents
    public java.lang.String getContents()
    Quick and dirty function to return the contents of this cell as a string.
    --> For more complex manipulation of the contents, it is necessary to cast this interface to correct subinterface
    Returns:
    the contents of this cell as a string

    In pratica suggerisce che per una manipolazione più complessa dei contenuti è necessario effettuare un cast sulla corretta sotto interfaccia... potresti provare a fare cast semplici e vedere cosa succede e poi leggendo un po' la documentazione ho visto che il metodo getValue() forse potrebbe essere applicato anche al tuo caso, sotto ti ho riportato il codice, prova afare delle prove con dei cast applicati a getContents() o anche ad usare il metodo getValue() abbinato o meno al getContents(), spero di averti aiutato.. bye!


    getValue() - Method in interface jxl.BooleanCell
    Gets the boolean value stored in this cell.
    getValue() - Method in interface jxl.NumberCell
    Gets the double contents for this cell.
    getValue() - Method in class jxl.format.Alignment
    Gets the value of this alignment.
    getValue() - Method in class jxl.format.BoldStyle
    Gets the value of the bold weight.
    getValue() - Method in class jxl.format.BorderLineStyle
    Gets the value for this line style
    getValue() - Method in class jxl.format.Colour
    Gets the value of this colour.
    getValue() - Method in class jxl.format.Orientation
    Accessor for the binary value
    getValue() - Method in class jxl.format.PaperSize
    Accessor for the internal binary value association with this paper size
    getValue() - Method in class jxl.format.Pattern
    Gets the value of this pattern.
    getValue() - Method in class jxl.format.ScriptStyle
    Gets the value of this style.
    getValue() - Method in class jxl.format.UnderlineStyle
    Gets the value of this style.
    getValue() - Method in class jxl.format.VerticalAlignment
    Accessor for the binary value
    getVersion() - Static method in class jxl.Workbook
    Accessor for the software version

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.