C# 导入word word导入

/// </summary>
        /// <param name="objFileRelativePath">导入Word文件拷贝在服务器上的全路径</param>
        /// <param name="sScript">出错时的提示信息</param>
        /// <param name="listRptID">导入生成报告的ID数组</param>
        /// <param name="strXMLPath">用于数据验证的XML文件名</param>
        /// <param name="strButID">导入按钮ID</param>
        private void ImportWord(ref object objFileRelativePath, StringBuilder sScript, ref ArrayList listRptID,string strXMLPath,string strButID)
        {

            Microsoft.Office.Interop.Word.ApplicationClass wordApp = null;
            object Missing = Type.Missing;
            Microsoft.Office.Interop.Word.Document wordDoc = null;
            using (clsDbAccept db = new clsDbAccept())
            {
                try
                {
                    wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
                    wordDoc = wordApp.Documents.Open(ref objFileRelativePath, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing,
                         ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing);
                    //导入报告的创建者为当前用户
                    string strCreater = Session["UserID"] != null ? Session["UserID"].ToString() : string.Empty;

                    #region XML文件,用于校验上传Word中数据的正确性
                    strXMLPath = this.Server.MapPath(clsCommon.GetUrl(this, strXMLPath));
                    DataSet dsXML = ReadXMLFile(strXMLPath);
                    //所有报告信息构成的表
                    DataTable dtTable = null;
                    //单个具体报告构成的表
                    DataTable dtCol = null;
                    //特殊报告项验证信息构成的表
                    DataTable dtColCondition = null;
                    DataView dvTable = null;
                    DataView dvCol = null;
                   

                    if (dsXML != null && dsXML.Tables.Count > 1)
                    {
                        dtTable = dsXML.Tables[0];
                        dtCol = dsXML.Tables[1];
                        if (dsXML.Tables.Count > 2)
                        {
                            dtColCondition = dsXML.Tables[2];
                        }
                    }
                    if (dtTable != null && dtTable.Rows.Count > 0)
                    {
                        dvTable = dtTable.DefaultView;
                        dvTable.RowFilter = string.Format("[TableType]='{0}'", strButID);
                        dtTable = dvTable.ToTable();
                    }

                    //表格内容开始行
                    int IntStartRowIndex = Convert.ToInt32(dtTable.Rows[0]["StartRowIndex&#

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值