import com.jxcell.ChartShape; import com.jxcell.RangeRef; import com.jxcell.View; public class CsvChartTest { public static void main(String args[]) { View m_view; try { m_view =new View(); m_view.read(".\\book.csv"); ChartShape chart = m_view.addChart((short)1, (short)9,(short)9, (short)22); chart.initData(new RangeRef(0,1,4,7),true); //Sheet1!$A$2:$E$8 m_view.write(".\\columnChart.xls"); chart.setChartType(ChartShape.TypeBar); m_view.write(".\\barChart.xls"); chart.setChartType(ChartShape.TypePie); m_view.write(".\\pieChart.xls"); chart.setChartType(ChartShape.TypeLine); m_view.write(".\\lineChart.xls"); chart.setChartType(ChartShape.TypeArea); m_view.write(".\\areaChart.xls"); chart.setChartType(ChartShape.TypePie); m_view.write(".\\pieChart.xls"); chart.setChartType(ChartShape.TypeDoughnut); m_view.write(".\\doughnutChart.xls"); chart.setChartType(ChartShape.TypeScatter); m_view.write(".\\scatterChart.xls"); chart.setChartType(ChartShape.TypeBubble); m_view.write(".\\bubbleChart.xls"); // Designer.newDesigner(m_view); } catch (Exception e) { e.printStackTrace(); } } }
默认:竖向的
TypeBar:横向柱状图
TypePie:饼状图
TypeLine:线状图
TypeArea:面积图
TypeDoughnut:圈图
TypeScatter:线点图
TypeBubble:没怎么看懂,就是一个灰图,不过查阅资料,貌似是泡状图
超链接(链接到另外的单元格、WEBSITE、E-MAIL、本地磁盘/文件)
import com.jxcell.*; import java.io.IOException; import com.jxcell.designer.Designer; public class Hyperlinks { public Hyperlinks() { View m_view = new View(); try { //Creating Hyperlink to another cell m_view.addHyperlink(1,1,1,1,"C3", HyperLink.kRange,"This is Workbook Link!"); //Creating Hyperlink for Website m_view.addHyperlink(2,1,2,1,"http://www.jxcell.net", HyperLink.kURLAbs,"This is Web Url Link!"); //Creating Hyperlink for e-mail m_view.addHyperlink(3,1,3,1,"mailto:support@jxcell.com", HyperLink.kURLAbs,"Send Mail!"); //Creating Hyperlink for Opening Files m_view.addHyperlink(4,1,4,1,"c:\\", HyperLink.kURLAbs,"This is File Link!"); m_view.write(".\\hyperlink.xls"); Designer.newDesigner(m_view); } catch (CellException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public static void main(String args[]) { new Hyperlinks(); } }