zoukankan      html  css  js  c++  java
  • Excel In C#

    在项目中需要导入Excel文件,其中需要把Excel格式的数据转换为我们私有格式。

    因此需要测试尽可能多的负数,于是乎写了如下的code进行测试:

    代码
    public void ExcelLoadSave(int targetValue,string fileName)
            {
                Excel._Application app 
    = new Excel.Application();
                app.Visible 
    = false;
                Excel.Workbooks wookbooks 
    = app.Workbooks;
                Excel._Workbook workbook 
    = app.Workbooks.Open(fileName, Excel.XlUpdateLinks.xlUpdateLinksUserSetting, false5""""false, Excel.XlPlatform.xlWindows, ""truefalsetruefalsetrue, Excel.XlCorruptLoad.xlNormalLoad);
                Excel._Workbook wookbook 
    = wookbooks.get_Item(1);
                Excel.Sheets sheets 
    = wookbook.Sheets;
                Excel._Worksheet ExcelSheet 
    = (Excel.Worksheet)sheets.get_Item(1);
                Excel.Range CellRange 
    = (Excel.Range)ExcelSheet.Cells[11];
                CellRange.Value2 
    = targetValue;
                workbook.Save();
                wookbook.Close(
    false, Missing.Value, Missing.Value);
                app.Quit();

                KillExcelProcess();

            }

            
    private void KillExcelProcess()
            {
                Process[] pss 
    = Process.GetProcesses();
                
    for (int i = 0; i < pss.Length; i++)
                {
                    
    if (pss[i].ProcessName == "EXCEL.EXE")
                    {
                        pss[i].Kill();
                    }
                }
            }
  • 相关阅读:
    让 ijkplayer 支持兼容armv7 armv7s
    以太网私网建立:同一台电脑,不同电脑运行多个节点。
    solidity 语言总结笔记
    web.js 方法详解
    Fabric 环境搭建
    浅谈区块链1
    以太坊私链建立和geth的使用
    搭建联盟链
    fabric 网络 合约部署 和 测试
    【Advanced Windows Phone Programming】番外篇 WP8与WP7
  • 原文地址:https://www.cnblogs.com/xixifusigao/p/1749120.html
Copyright © 2011-2022 走看看