vs2010导入word表格
来源:互联网 发布:云盘搭建php源码 编辑:程序博客网 时间:2024/05/17 04:12
var fileName = sle_1.GetText();
if (fileName == "") {
requestor.MessageBox("提示", "请选择要导入的Word文件!", ICON.StopSign);
sle_1.SetFocus();
return;
}
requestor.MessageBox("提示", "文件 " + fileName + " 不存在,请检查!", ICON.StopSign);
return;
}
requestor.MessageBox("提示", "上传的文件不能大于1M,请重新选择!", ICON.StopSign);
return;
}
//取文件内容的Base64的内容,即把文件由二进制,转为字符串,以便作为一般的表单内容上传到服务器
if (fileBase64 == "")
return;
webReq.Invoke("AppointImport", "filedata=" + fileBase64);
if (webReq.StatusCode() == 200) {
requestor.MessageBox("提示", "导入成功!");
}
else {
requestor.MessageBox("提示", webReq.ResponseText(), ICON.StopSign);
}
protected void AppointImport()
{
MemoryStream ms = null;
string years = Request["years"].ToString();
byte[] fileData = GZip.UnCompress(Base64.Decode(Request.Form["filedata"].ToString()));
ms = new MemoryStream(fileData, 0, fileData.Length);
var document = ParseDocument1(ms);
this.DBHelp.BeginTransAction();
try
{
SqlCommand cmd = this.DBHelp.GetCommand("INSERT INTO T_Appoint"+
"(ID,Years,Name,Sex) Values(" +
"@ID,@Years,@Name,@Sex)");
cmd.Parameters.Add(new SqlParameter("@ID", document.ID));
cmd.Parameters.Add(new SqlParameter("@Years", years));
cmd.Parameters.Add(new SqlParameter("@Name", document.Name));
cmd.Parameters.Add(new SqlParameter("@Sex", document.Sex));
cmd.ExecuteNonQuery();
this.DBHelp.Commit();
}
catch (Exception ex)
{
this.DBHelp.Rollback();
this.SetErrorInfo("导入时发生错误。\r\n错误信息为:\r\n" + ex.Message);
}
}
public static AppointAprovalSubmitModel ParseDocument1(Stream stream)
{
try
{
var doc = DocX.Load(stream);
var tables = doc.Tables;
if (tables.Count == 0)
throw new Exception("The uploaded document does not contain a table");
var table = tables[0];
return new AppointAprovalSubmitModel()
{
ID = System.Guid.NewGuid().ToString("D"),
Name = table.GetCell(0, 1),
Sex = table.GetCell(0,3),
Nation = table.GetCell(0, 5),
//DateUploaded = DateTime.Now,
};
}
catch (Exception ex)
{
throw new Exception("Unable to parse the uploaded document. See inner exception for details", ex);
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using TXSoft.DataStore;
using System.Text;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Novacode;
using TXSoft.Common;
using System.Reflection;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
- vs2010导入word表格
- 将 Excel 表格导入 Word
- VS2010 操作Word(三)表格操作
- VS2010写WORD(二)表格操作
- vs2010导入导出excel表格代码
- 将浏览器表格导入到word
- python读取excel导入word表格
- 页面的表格导入到WORD文件中去
- 把html的表格导入到excel,word中
- ASP中的表格导入到Word中打印
- 把html的表格导入到excel,word中
- java读取word表格导入数据库,支持doc、docx
- 将word中表格批量导入到Excel
- word导入
- C# 导入word word导入
- 使用VBA将Excel数据导入到Word的表格中
- 毕业设计同学们的福利(将word表格导入PowerDesigner中实现快速创建PDM)
- CKeditor导入WORD,保留完整的图片和表格。只支持IE内核的浏览器
- golang和python有关字符串操作的对应方法
- MFC总结(11) ---- 添加/删除 开机启动项
- js翻页,待转成c#的
- Android Fragment 真正的完全解析(上)
- css3的background-size兼容IE低版本
- vs2010导入word表格
- 标准DPCM编码(Matlab实现)
- sql语法 DISTINCT 和 TOP 和 order by
- iOS中block实现的探究
- genymotion 安装过程和出现的问题解决方案汇总
- 导出csv文件中文乱码问题
- Spark RDD中Transformation的combineByKey、reduceByKey,join详解
- Android Studio 系列文章(10)—AS中获取SHA1值
- delphi 三层架构简单例