【c#】15. ExcelMechanisms

34 篇文章 1 订阅
7 篇文章 0 订阅
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);
        }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值