我想繪製jFreeChart在使用apache POI的word文檔,但我無法做到這一點。在這裏,我所做的我不知道哪一個我必須使用適當有人請我help.here我已經截至目前完成的,參數是不正確的,同時生成單詞與POI
JFreeChart TotalActivityChart = ChartFactory.createBarChart("Total Activities", "Activities", "#Candidate", bar_chart_servlet, PlotOrientation.VERTICAL, false, true, false);
/**---------------------------------- Appearance of chart for Total Activity------------------------------------ */
// Adjust appearance (optional)
TotalActivityChart.getTitle().setPaint(Color.BLACK);
TotalActivityChart.setAntiAlias(true);
CategoryPlot plot = (CategoryPlot) TotalActivityChart.getPlot();
plot.setBackgroundPaint(new GradientPaint(0, 0, Color.DARK_GRAY, 0, 100, Color.GRAY));
// set the range axis to display integers only...
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
final CategoryItemRenderer renderer = new CustomRenderer(new Paint[] { new Color(0x3D59AB), new Color(0x009ACD), new Color(0x104E8B), new Color(0x50A6C2) });
plot.setRenderer(renderer);
/**--------------------------------------- End of Appearance of Chart--------------------------------------- */
int width = 800;
int height = 240;
ByteArrayOutputStream chart_out = new ByteArrayOutputStream();
ChartUtilities.writeChartAsPNG(chart_out, TotalActivityChart, width, height);
String pictureIdx = document.addPictureData(chart_out.toByteArray(), Workbook.PICTURE_TYPE_PNG);
chart_out.close();
int width = 800;
int height = 240;
ByteArrayOutputStream chart_out = new ByteArrayOutputStream();
ChartUtilities.writeChartAsPNG(chart_out, TotalActivityChart, width, height);
String pictureIdx = document.addPictureData(chart_out.toByteArray(), document.PICTURE_TYPE_PNG);
//document.createParagraph().createRun().addPicture(chart_out, Document.PICTURE_TYPE_PNG,"my pic", Units.toEMU(200), Units.toEMU(200));
chart_out.close();
run.addPicture(new FileInputStream(pictureIdx), Document.PICTURE_TYPE_PNG, pictureIdx, Units.toEMU(200), Units.toEMU(200));
// Setup the output
String contentType="application/msword";
response.addHeader("Content-Disposition", "attachment; filename=\""+ "reportName" + ".docx\"");
response.setContentType(contentType);
ServletOutputStream out = response.getOutputStream();
document.write(out);
任何一個可以建議如何添加的圖片中這個詞doc..Thanks提前
看起來你已經有了它產生的PNG圖像,是嗎?如果是這樣,爲什麼不使用Apache POI將它添加到word文檔的正確位置? – Gagravarr 2014-12-19 09:05:26
我怎麼能做到這一點? – lucifer 2014-12-19 09:06:18
我如何添加可以請你幫忙? – lucifer 2014-12-19 09:28:57