using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UserDefinedDataEXP
{
class ExcelMechanisms
{
private static ExcelDriver excel;
static ExcelMechanisms()
{ // This static constructor ensures that only one
// instance of Excel is started.
excel = new ExcelDriver();
excel.MakeVisible(true);
}
public ExcelMechanisms()
{
}
// etc.
// 函数printAssocMatrixInExcel
// Print a two-dimensional associative array (typically, one time level);
// Recall: row, column and value parameters
public void printAssocMatrixInExcel<R, C, T>(AssocMatrix<R, C, T> matrix, string SheetName)
{
excel.AddAssocMatrix(matrix, SheetName);
}
//把二叉树或者三叉树打印到Excel
public void printLatticeInExcel(Lattice<double> lattice, Vector<double> xarr, string SheetName)
{
List<string> rowlabels = new List<string>();
for (int i = xarr.MinIndex; i <= xarr.MaxIndex; i++)
{
rowlabels.Add(xarr[i].ToString());
}
excel.AddLattice(SheetName, lattice, rowlabels);
}
//把(x,y)生成Excel图
public void printOneExcel<T>(Vector<T> x, Vector<T> y, string title, string horizontal, string vertical, string legend)
{
// N.B. Excel has limit of 8 charts; after that a run-time error
ExcelDriver excel = new ExcelDriver();
excel.MakeVisible(true); // Default is INVISIBLE!
excel.CreateChart<T>(x, y, title, horizontal, vertical,legend);
}
}
}