2

我创建了一个 csv 文件,

并将数据库中的数据显示到该文件中,

如何将饼图添加到该文件,

这是我制作的代码:

File file = new File("C:/Users/MY TOSHIBA/Desktop/chart.CSV");
Writer output =null;
output = new BufferedWriter(new FileWriter(file));
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@ 127.0.0.1:1521:XE","username","password");
String sql="select * from table";
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while(rs.next())
{
String teller =rs.getString("name");
String flag=rs.getString("flag");
output.write(teller+flag+"\n");
}
output.close();
4

1 回答 1

1

First, you can't create charts in Text files.

If your question is about creating charts in excel using Java, you have to use ApachePOI. It will not create charts from the scratch, but it can link a chart from somewhere else to your excel file.

Create excel chart using Apache POI

However, I found the following in google, which seems like something, which is capable of doing what you are asking for

http://www.smartxls.com/java/drawings-charts.htm#vdrawings-charts-chart

于 2012-12-18T17:00:56.990 回答