Bonjour,
Je cherche à créer des fichiers excel (xls) contenant des histogrammes.
POI et Jexcel me permettent de créer des xls mais pas d'y ajouter des histogrammes....
Quelqu'un a une idée ?
Version imprimable
Bonjour,
Je cherche à créer des fichiers excel (xls) contenant des histogrammes.
POI et Jexcel me permettent de créer des xls mais pas d'y ajouter des histogrammes....
Quelqu'un a une idée ?
Bonsoir,
Si tu essaie de créer le xls et l'histogramme avant et que ensuite tu rentre les données excel avec java ca fonctionne mais pour creer l'histogramme directement avec POI je ne sais pas désolé :(
j'ai le mème problème :j'ai un fichier excel contenant un histogramme qui est construit automatiquement à partir d'un tableau de valeurs qui est présent aussi sur le fichier excel et je veux visualiser ces histogrammes sur une interface graphique en java svp pouvez vous m'aider svp?
D'après la documentation de Apache POI, cette possibilité est intégrée dans poi 3.8. Voici un exemple de code pour le créer un histogramme en partant de zéro avec un programme Java :
De mémoire 'après certains Dans les verisons antérieures, il faut :Code:
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
50
51
52
53
54
55
56
57
58
59
60
61 package org.apache.poi.xssf.usermodel.examples; import java.io.FileOutputStream; import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.*; import org.apache.poi.ss.usermodel.charts.*; import org.apache.poi.xssf.usermodel.XSSFWorkbook; /** * Illustrates how to create a simple scatter chart. * * @author Roman Kashitsyn */ public class ScatterChart { public static void main(String[] args) throws Exception { Workbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet("Sheet 1"); final int NUM_OF_ROWS = 3; final int NUM_OF_COLUMNS = 10; // Create a row and put some cells in it. Rows are 0 based. Row row; Cell cell; for (int rowIndex = 0; rowIndex < NUM_OF_ROWS; rowIndex++) { row = sheet.createRow((short) rowIndex); for (int colIndex = 0; colIndex < NUM_OF_COLUMNS; colIndex++) { cell = row.createCell((short) colIndex); cell.setCellValue(colIndex * (rowIndex + 1)); } } Drawing drawing = sheet.createDrawingPatriarch(); ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 5, 10, 15); Chart chart = drawing.createChart(anchor); ChartLegend legend = chart.getOrCreateLegend(); legend.setPosition(LegendPosition.TOP_RIGHT); ScatterChartData data = chart.getChartDataFactory().createScatterChartData(); ValueAxis bottomAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.BOTTOM); ValueAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT); leftAxis.setCrosses(AxisCrosses.AUTO_ZERO); ChartDataSource<Number> xs = DataSources.fromNumericCellRange(sheet, new CellRangeAddress(0, 0, 0, NUM_OF_COLUMNS - 1)); ChartDataSource<Number> ys1 = DataSources.fromNumericCellRange(sheet, new CellRangeAddress(1, 1, 0, NUM_OF_COLUMNS - 1)); ChartDataSource<Number> ys2 = DataSources.fromNumericCellRange(sheet, new CellRangeAddress(2, 2, 0, NUM_OF_COLUMNS - 1)); data.addSerie(xs, ys1); data.addSerie(xs, ys2); chart.plot(data, bottomAxis, leftAxis); // Write the output to a file FileOutputStream fileOut = new FileOutputStream("ooxml-scatter-chart.xlsx"); wb.write(fileOut); fileOut.close(); } }
1- Créer un template excel avec un histogramme
2- Lier l'histogramme à des données
3- Modifier dynamiquement les données pour avoir son histogramme.
Bon courage.
Merci pracede2005 !
Cela fait un moment que je cherche à générer des graphes Excel à partir de Java ! Sinon vs connaissez ou je peux trouver des tutos ou documentation quelconque pour générer les graphes ...... Merci