请教高手,如果用DELPHI将数据导入到EXCEL里面后做柱状图?

解决方案 »

  1.   

    http://community.borland.com/article/0,1410,10129,00.htmlNow that you have a worksheet, and some data, then next step is to create a graph. The following procedure from the Excel4 program should get you started working with charts: 
    procedure TForm1.ChartData;
    var
      ARange: Variant;
      Sheets: Variant;
    begin
      XLApp.Workbooks[1].Sheets.Add(,,1,xlChart);
      Sheets := XLApp.Sheets;
      ARange := Sheets.Item['Delphi Data'].Range['A1:A10'];
      Sheets.Item['Chart1'].SeriesCollection.Item[1].Values := ARange;
      Sheets.Item['Chart1'].ChartType := xl3DPie;
      Sheets.Item['Chart1'].SeriesCollection.Item[1].HasDataLabels := True;  XLApp.Workbooks[1].Sheets.Add(,,1,xlChart);
      Sheets.Item['Chart2'].SeriesCollection.Item[1].Values := ARange;
      Sheets.Item['Chart2'].SeriesCollection.Add(ARange);
      Sheets.Item['Chart2'].SeriesCollection.NewSeries;
      Sheets.Item['Chart2'].SeriesCollection.Item[3].Values :=
        VarArrayOf([1,2,3,4,5, 6,7,8,9,10]);
      Sheets.Item['Chart2'].ChartType := xl3DColumn;
    end;改變這個就行
    Sheets.Item['Chart1'].ChartType := xl3DPie;
      

  2.   

    300就300
    我告诉你With exSheet.Application    .Range(.Cells(1, 1), .Cells(i, j)).Select    Set oRange = exSheet.Application.Selection    .Charts.Add
        
        Select Case Me.ChartTime.ChartType
            
            Case VtChChartType2dLine ''折线图
            
            .ActiveChart.ChartType = xlLineMarkers
            
            Case VtChChartType2dBar ''柱状图
            
            .ActiveChart.ChartType = xlColumnClustered
        
        End Select    .ActiveChart.SetSourceData oRange, xlRows    .ActiveChart.Location xlLocationAsNewSheet    With .ActiveChart        .HasTitle = True        .ChartTitle.Characters.Text = Me.ChartTime.Title
            
            .Axes(xlValue, xlPrimary).HasTitle = True
            
            .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "天"
            
            .Axes(xlValue).AxisTitle.Select
            
            With .Application.Selection
                
                .HorizontalAlignment = xlCenter
                
                .VerticalAlignment = xlTop
                
                .ReadingOrder = xlLTR
                
                .Orientation = xlHorizontal
                
            End With    End WithEnd With先把数据写到一个sheet里面,然后选中这些数据,按上面操作
    或者你把要求给我看看,我帮你写,delphi写,呵呵
    上面的是我前天用vb写的
    我不要分