2017-03-03 43 views
0

NPOIバージョン2.2.1NPOIを使用して、Excelでチャート軸を描画する方法は?

生成するサンプルコードは折れ線グラフで生成されますが、グラフが生成されたときに軸はありません。

bottomAxisのプロパティ(IsVisible)は既にtrueですが、まだ見ることはできません。

私の質問は、それらの軸を表示させる方法です。 deafultがTrueのとき

Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load 

    Dim wb As IWorkbook = New XSSFWorkbook() 
    Dim ws As ISheet = wb.createSheet("linechart") 
    Dim NUM_OF_ROWS = 3 
    Dim NUM_OF_COLUMNS = 10 


    For rowIndex As Integer = 0 To NUM_OF_ROWS 
     Dim row = ws.CreateRow(rowIndex + 1) 
     For colIndex As Integer = 0 To NUM_OF_COLUMNS 
      Dim cell = ws.GetRow(rowIndex + 1).CreateCell(colIndex) 
      cell.setCellValue(colIndex * (rowIndex + 1)) 
     Next 

    Next 
    Dim drawing = ws.createDrawingPatriarch() 
    Dim anchor = drawing.createAnchor(0, 0, 0, 0, 0, 5, 10, 15) 
    Dim chart As IChart = drawing.createChart(anchor) 
    Dim legend = chart.getOrCreateLegend() 

    Dim dataFactory = chart.ChartDataFactory 
    Dim chartAxisFactory = chart.ChartAxisFactory 

    Dim lineChartData = dataFactory.createLineChartData(Of Double, Double)() 
    Dim bottomAxis = chartAxisFactory.createCategoryAxis(NPOI.SS.UserModel.Charts.AxisPosition.BOTTOM) 
    Dim leftAxis = chartAxisFactory.createValueAxis(NPOI.SS.UserModel.Charts.AxisPosition.RIGHT) 


    Dim xs = NPOI.SS.UserModel.charts.DataSources.fromNumericCellRange(ws, New NPOI.SS.Util.CellRangeAddress(0, 0, 0, NUM_OF_COLUMNS - 1)) 
    Dim ys1 = NPOI.SS.UserModel.charts.DataSources.fromNumericCellRange(ws, New NPOI.SS.Util.CellRangeAddress(1, 1, 0, NUM_OF_COLUMNS - 1)) 
    Dim ys2 = NPOI.SS.UserModel.charts.DataSources.fromNumericCellRange(ws, New NPOI.SS.Util.CellRangeAddress(2, 2, 0, NUM_OF_COLUMNS - 1)) 


    lineChartData.addSeries(xs, ys1) 
    lineChartData.addSeries(xs, ys2) 

    chart.plot(lineChartData, bottomAxis, leftAxis) 

    Dim file As FileStream = New FileStream("D:/feed//Xiaohongshu/" & "test" & ".xlsx", FileMode.Create) 
    wb.Write(file) 
    file.Close() 


End Sub 

答えて

0

これは、我々はFalseにのisVisibleを設定する必要がNPOI 2.2.1 ためのバグかもしれ

bottomAxis.IsVisible = False 
leftAxis.IsVisible = False 
関連する問題