给SpreadSheet控制加上状态栏,实现自动求和等操作
如下代码实现:private void spreadsheetControl1_SelectionChanged(object sender, EventArgs e) {
Range selectedRange = spreadsheetControl1.Document.Worksheets[0].Selection;
if(selectedRange.ColumnCount > 1 || selectedRange.RowCount > 1) {
string averageValue = spreadsheetControl1.Document.Evaluate(String.Format("=AVERAGE({0})", selectedRange.GetReferenceA1())).ToString();
string sumValue = spreadsheetControl1.Document.Evaluate(String.Format("=SUM({0})", selectedRange.GetReferenceA1())).ToString();
barStaticItem2.Caption = String.Format("Average: {0}, Sum: {1}", averageValue, sumValue);
}
else barStaticItem2.Caption = "";
}
页:
[1]