public void CreateChart()
{
Excel.Worksheet thisWorksheet;
thisWorksheet = thisWorkbook.ActiveSheet as Excel.Worksheet;
Excel.ChartObjects charts =
(Excel.ChartObjects)thisWorksheet.ChartObjects(Type.Missing);
// Adds a chart at x = 100, y = 300, 500 points wide and 300 tall.
Excel.ChartObject chartObj = charts.Add(100, 300, 500, 300);
Excel.Chart chart = chartObj.Chart;
// Gets the cells that define the bounds of the data to be charted.
Excel.Range chartRange = thisWorksheet.get_Range("A5","D8");
chart.SetSourceData(chartRange,Type.Missing);
chart.ChartType = Excel.XlChartType.xlXYScatter;
Excel.SeriesCollection seriesCollection=
(Excel.SeriesCollection)chart.SeriesCollection(Type.Missing);
Excel.Series series = seriesCollection.Item(seriesCollection.Count);
}
Find something in google.
Excel excel = new Excel();
Worksheet sheet = excel.Worksheets[0];
Cells cells = sheet.Cells;
cells[0,1].PutValue("Income");
cells[1,0].PutValue("Company A");
cells[2,0].PutValue("Company B");
cells[3,0].PutValue("Company C");
cells[1,1].PutValue(10000);
cells[2,1].PutValue(20000);
cells[3,1].PutValue(30000);
int chartIndex = sheet.Charts.Add(ChartType.Column, 9, 9, 21, 15);
Chart chart = sheet.Charts[chartIndex];
chart.NSeries.Add("B2:B4", true);
chart.NSeries.CategoryData = "A2:A4";
ASeries aSeries = chart.NSeries[0];
aSeries.Name = "=B1";
chart.IsLegendShown = true;
chart.Title.Text = "Income Analysis";
设置excel自动筛选
Sample_sheet.get_Range("A4", Type.Missing).EntireRow.AutoFilter(1,Type.Missing,Excel.XlAutoFilterOperator.xlAnd,Type.Missing,true);