• 取得excel有效信息


              //0/加入using Excel; 

              string strFileName = "test.xls";
                //1、判斷file this.Server.MapPath(strFileName)存在
                //2、取信息
                object missing = System.Reflection.Missing.Value;

                ApplicationClass appc = new ApplicationClass();//lauch excel application

                if (appc != null)
                {
                    //open excel file
                    if (appc.Application.Workbooks != null)
                    {
                        Workbook wb = appc.Application.Workbooks.Open(this.Server.MapPath(strFileName), missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);

                        int srow = 2;
                        int erow = ws.UsedRange.Rows.Count;
                        int scolumn = 1;
                        int ecolumn = ws.UsedRange.Columns.Count;
                        for (int irow = srow; irow <= erow; irow++)
                        {
                            strValue += "Row" + (irow-1);
                            for (int icolu = scolumn; icolu <= ecolumn; icolu++)
                            {
                                strValue += " Cell" + icolu + ":" + ((Range)ws.Cells.get_Item(irow, icolu)).Value2.ToString();
                            }
                            strValue += "<br/>";
                        }
                        this.Response.Write(strValue);
                    }

                }
                appc.Quit();

                appc = null;

  • 相关阅读:
    NC_6_TREE_MAX_PATH
    NC_12_reConstructBinaryTree
    NC_15_levelOrder
    NC_7_MAXPROFIT
    NC_9_HAS_PATH_SUM
    NC_8_BINARYTREE_SUMPATH
    NC_13_MAX_DEPTH
    IDEA的基本使用:让你的IDEA有飞一般的感觉
    Java获取当前系统事件System.currentTimeMillis()方法 ,获取当前时间戳10位 1665291145 转为时间字符串 yyyMMdd
    JAVA中计算两个日期时间的差值竟然也有这么多门道
  • 原文地址:https://www.cnblogs.com/freeliver54/p/1274652.html
Copyright © 2020-2023  润新知