1
我想不过来获得一个工作表中的最低值,当我生成最小,并将其放置在一个单元格,然后提取该值我得到整个公式,而不是在细胞的双重价值....我做错了什么?下面是我的生成图的方法。如何获得一个值,而不是公式
另一件事,我也想删除图形后,我将它保存我试图.delete(),但只是把和错误,我怎么去这样做
private void GenerateGraph(Worksheet worksheet, int lastRow, int lastColumn, string filename)
{
string topLeft = ToCell(0, 0);
string bottomRight = ToCell(lastRow - 1, lastColumn - 1);
worksheet.get_Range(ToCell(0, 0), missing).Formula = "Max(B2:" + bottomRight + ")";
worksheet.get_Range(ToCell(0, 0), missing).FormulaHidden = true;
worksheet.get_Range(ToCell(0, 0), missing).Calculate();
Range range = (Range)worksheet.Cells[1,1];
//
//here is where my problem is, small is being given the formula from above
//
string small = (string)range.Value2;
double min = Convert.ToDouble(small);
worksheet.get_Range(ToCell(0,0),missing).Formula = "";
//Generates the graph
range = worksheet.get_Range(topLeft, bottomRight);
ChartObjects Xlchart = (ChartObjects)worksheet.ChartObjects(missing);
ChartObject chart = (ChartObject)Xlchart.Add(20, 160, 600, 500);
Excel.Chart myChart = chart.Chart;
myChart.SetSourceData(range, missing);
//sets the y axis
Axis axis = (Axis)myChart.Axes(XlAxisType.xlValue, XlAxisGroup.xlPrimary);
axis.MinimumScaleIsAuto = true;
axis.MaximumScaleIsAuto = true;
axis.HasTitle = true;
axis.AxisTitle.Text = "Measure (m)";
axis.CrossesAt = (int)(min-1);
//sets the x axis
Axis xAxis = (Axis)myChart.Axes(XlAxisType.xlCategory, XlAxisGroup.xlPrimary);
xAxis.HasTitle = true;
xAxis.AxisTitle.Text = "Position (m)";
//makes the graph a line graph
myChart.ChartType = XlChartType.xlXYScatterLinesNoMarkers;
//titles the graph
myChart.HasTitle = true;
myChart.ChartTitle.Text = "Profiles";
//saves the graph
myChart.Export(filename, "JPG", missing);
//
//here is where I would like to delete the graph
//
}
那我,那解决我的问题的前半部分,现在我该怎样从实际Excel中删除图形文件? – 2011-02-23 14:54:59
@Bob这是有问两个问题一个问题。我知道第一个答案,但不是第二个答案。你会更好编辑这个问题上的删除部分,然后要求只包含一个新的问题! – 2011-02-23 15:02:49