zoukankan      html  css  js  c++  java
  • c#操作excel的一些记录

    //开启Excel APP
                Excel.Application xlApp = new Excel.Application();

    //获取程序下bin—>debug下的文件夹的两种方法(System.IO.Directory.GetCurrentDirectory();System.AppDomain.CurrentDomain.BaseDirectory )

    //读取模板

    sTemplateFilePath = System.IO.Directory.GetCurrentDirectory() + "\ExcelTempFile\直通率.xlsx";

     //开启模板档案
                Excel.Workbook xlBook = xlApp.Workbooks.Open(sTemplateFilePath, Type.Missing, Type.Missing, Type.Missing
                                                    , Type.Missing, Type.Missing, Type.Missing, Type.Missing
                                                    , Type.Missing, Type.Missing, Type.Missing, Type.Missing
                                                    , Type.Missing, Type.Missing, Type.Missing);

     //取得模板的sheets页面用于写入数据
                            Excel.Worksheet RtySheet= (Excel.Worksheet)xlBook.Worksheets["SheetTemp1"];

    // Excel.Range oRange1 =RtySheet.get_Range() 用于取得excel中的区域

    对excel列是用第一行的字母加第一列的序号来取得位置的;

    具体想获取操作的代码可用宏录制;

    简单配置xml 并读取数据存入模型

     #region 读取xml中的元素存入list<>;
                List<XMLAutoMailModel> listXML = new List<XMLAutoMailModel>();
                string settingFile = System.AppDomain.CurrentDomain.BaseDirectory + "bin\AutoMailXML.xml";
                XmlDocument doc = new XmlDocument();
                doc.Load(settingFile);
                XmlElement elm = doc.DocumentElement;
                XmlNode node = elm.SelectSingleNode("ProSetting");
                foreach (XmlNode sheet in node.ChildNodes)
                {
                    XMLAutoMailModel xmlAutoModel = new XMLAutoMailModel();
                    if (sheet.Name == "sheet")
                    {

                        xmlAutoModel.Key = sheet.Attributes["Key"].Value;
                        xmlAutoModel.SheetName = sheet.Attributes["SheetName"].Value;
                        xmlAutoModel.ChartTitle = sheet.Attributes["ChartTitle"].Value;
                        foreach (XmlNode condition in sheet.ChildNodes)
                        {
                            xmlAutoModel.ProdType = condition.Attributes["ProdType"].Value;
                            xmlAutoModel.Products = condition.Attributes["Products"].Value;
                        }
                    }
                    listXML.Add(xmlAutoModel);
                }
                #endregion

  • 相关阅读:
    Brain network involved in autonomic functions 与自主功能相关的大脑网络
    Brief summary of classical components of ERP 事件相关成分(ERP)经典成分小结
    ICA & Percentage Variance Account For (PVAF)
    数据处理中白化Whitening的作用图解分析
    Loadings vs eigenvectors in PCA 主成分分析(PCA)中的负荷和特征向量
    主成分分析(PCA)和独立成分分析(ICA)相关资料
    Sketch of heart and QRS complex 心脏及QRS波群简图
    Brain Network visulation in EEG 脑电网络可视化
    Phase Locking Value (PLV) 神经信号的锁相值
    ubuntu16.04下的一些基本操作笔记
  • 原文地址:https://www.cnblogs.com/fighting2014/p/4016308.html
Copyright © 2011-2022 走看看