Bonjour
J'utilise l'API jxl pour lire un fichier excel
j'ai un petit problème avec
Je souhaiterai obtenir les débuts et fin de lignes et de coloones effectivement remplies par mon tableur excel. Il existe pour celà des méthodes getStartColumn(), getEndColumn() dans la classe ColumnInfoRecord et getRowHeight(), getRowNumber dans la classe RowRecord
Je ai essayé getStartColumn() mais je n'arrive pas à implémenter ce code:
int Ncolonnes=ColumnInfoRecord.getStartColumn();
Il me met le méssage d'erreur suivant
Cannot make a static reference to the non static method getStartColumn from the type ColumnInfoRecord.
Avez vous un code qui marche?
Dans ces cas là, il faut implémenter un objet
objet.methode() à la place de classe.methode() mais je ne sais pas quel objet utiliser ni comment le créer.
Si j'ai la solution pour geStartColumn(), je pense que je pourrai le faire pour les autres.
Merci par avence de votre aide
Voici mon code pour information
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
import java.io.File;
import java.io.IOException;
import jxl.*;
import jxl.read.biff.BiffException;
import jxl.read.biff.ColumnInfoRecord;
public class Lire {
/**
* @param args
* @throws IOException
* @throws BiffException
* @throws IOException
* @throws BiffException
*/
//int c=this.addition(5, 7);
//int Ncolonnes=ColumnInfoRecord.getStartColumn();
public static void main(String[] args) throws BiffException, IOException{
// TODO Auto-generated method stub
//getCellReference(int a,int b,Workbook);
int Ncolonnes=ColumnInfoRecord.getStartColumn();
String tab[][]=new String [30][200];
for (int i=0;i<8;i++){
for (int j=0;j<4;j++){
Workbook workbook = Workbook.getWorkbook(new File("C:/Documents and Settings/Olivier/Mes Documents/test.xls"));
Sheet sheet = workbook.getSheet(0);
Cell b2= sheet.getCell(j,i);
String stringb2= b2.getContents();
tab[j][i]=stringb2;
System.out.println("la lettre choisie est "+tab[j][i]+" pour i="+i+" et j="+j);
}
}
/* //String sNumber="235.98";
//float fNumber=Float.parseFloat(sNumber);
//System.out.println("valeur: "+fNumber);*/
// Do stuff with the strings etc
// Finished - close the workbook and free up memory
// Do stuff with dates and doubles
}
} |
Partager