如何将查询结果导出到Excel文件?

时间:2018-04-15 16:23:31

标签: sql excel netbeans

给出以下查询:

     String SQL = "select name,years from person"; 
     ps = con.createStatement();
     rs = ps.executeQuery(SQL);
     jTable1.setModel(DbUtils.resultSetToTableModel(rs));

如何轻松将数据导出到Excel文件?

谢谢

1 个答案:

答案 0 :(得分:0)

func configure (dataPoints: [String], values: [Double]) {
    chartIMG.noDataText = "Please Insert Some Data!"

    var dataEntries: [ChartDataEntry] = []

    for i in 0..<dataPoints.count {
        let dataEntry = ChartDataEntry(x: values[i], y: Double(i))
        dataEntries.append(dataEntry)


    }



    let pieChartDataSet = PieChartDataSet(values: dataEntries, label: "Symptoms")
    let pieChartData = PieChartData(dataSet: pieChartDataSet)
    chartIMG.data = pieChartData

    let noZeroFormatter = NumberFormatter()
    noZeroFormatter.zeroSymbol = ""
    pieChartDataSet.valueFormatter = DefaultValueFormatter(formatter: noZeroFormatter)

    var colors: [UIColor] = []

    for i in 0..<dataPoints.count {
        let red = Double(arc4random_uniform(256))
        let green = Double(arc4random_uniform(256))
        let blue = Double(arc4random_uniform(256))

        let color = UIColor(red: CGFloat(red/255), green: CGFloat(green/255), blue: CGFloat(blue/255), alpha: 1)
        colors.append(color)
    }


    chartIMG.highlightPerTapEnabled = false
    chartIMG.usePercentValuesEnabled = false
    chartIMG.drawEntryLabelsEnabled = true
    chartIMG.centerText = "%"


    let legend = chartIMG.legend
    legend.font = UIFont(name: "Arial", size: 11)!
    legend.textColor = UIColor.black
    legend.form = .circle

    chartIMG.animate(xAxisDuration: 2, yAxisDuration: 2)

    pieChartDataSet.colors = colors
    pieChartDataSet.selectionShift = 0
    pieChartDataSet.sliceSpace = 2.5


}