c# - how to get a value and not the formula -


i trying obtain minimum value worksheet when generate minimum , place in cell, , extract value getting entire formula , not double value in cell.... doing wrong? below generate graph method.

another thing, delete graph after save have tried .delete() threw , error, how go doing that

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 problem is, small being given formula above         //          string small = (string)range.value2;         double min = convert.todouble(small);         worksheet.get_range(tocell(0,0),missing).formula = "";          //generates 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 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 x axis         axis xaxis = (axis)mychart.axes(xlaxistype.xlcategory, xlaxisgroup.xlprimary);         xaxis.hastitle = true;         xaxis.axistitle.text = "position (m)";          //makes graph line graph         mychart.charttype = xlcharttype.xlxyscatterlinesnomarkers;          //titles graph         mychart.hastitle = true;         mychart.charttitle.text = "profiles";          //saves graph         mychart.export(filename, "jpg", missing);          //         //here delete graph         //     } 

you need:

formula = "=max(b2:" + bottomright + ")" 

you missing equals sign in formula.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -