1.doc文件已经上传到数据库
表名:laba
字段名:doctest如何从数据库中读出并保存到c盘根目录 ,名为 2.doc 文件呢?c# winform 方式
表名:laba
字段名:doctest如何从数据库中读出并保存到c盘根目录 ,名为 2.doc 文件呢?c# winform 方式
解决方案 »
- 关于多次拨号得到的多个IP指定IP访问出去
- 分析器错误消息: 未能加载文件或程序集“Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=ne
- 问两个简单问题:排序和表达式分析
- listview选中行的问题
- 用win2008R2作服务器的朋友请进!!!!
- 高分请教关于文件流格式输出问题??
- 请问怎样编程从IE Temporary Internet Files文件夹中复制JPG文件到其他目录?(内空)
- Datagridview中默认以绑定表字段作为标题,如何更改列标题?
- 连接数据库问题
- bs结构读页面问题
- C#做打印位置调整该怎么做?
- update语法错误?
public static void StringToWord(Application oword,Document odoc,Object Nothing, string str)
{
try
{
Paragraph oPara1;
oPara1 = odoc.Content.Paragraphs.Add(ref Nothing); oPara1.Range.Text = str;
//oPara1.Range.Font.Bold = 0;
//oPara1.Format.SpaceAfter = 24;
oPara1.Range.InsertParagraphAfter();
//return odoc;
}
catch (Exception ex) { Log.WriteErLog(ex.Message); }
finally
{
System.Diagnostics.Process[] CurrentProcess = System.Diagnostics.Process.GetProcessesByName("WINWORD");
for (int i = 0; i < CurrentProcess.Length; i++)
{
if (CurrentProcess[i].MainWindowHandle.ToInt32() == 0)
{
try
{
CurrentProcess[i].Kill();
}
catch
{
}
}
} }
}
/// 导出的数据string
/// </summary>
/// <param name="str"></param>
public static void StringToWord(string str)
{
Object Nothing = System.Reflection.Missing.Value;
Application oword = new Application();//word Application
Document odoc = oword.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);//文档
//odoc.Paragraphs.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
odoc.Paragraphs.Alignment = WdParagraphAlignment.wdAlignParagraphLeft; try
{
oword.Visible = true;
Paragraph oPara1;
oPara1 = odoc.Content.Paragraphs.Add(ref Nothing);
oPara1.Range.Text = str;
oPara1.Range.Font.Bold = 1;
oPara1.Format.SpaceAfter = 24;
oPara1.Range.InsertParagraphAfter();
}
catch (Exception ex) { Log.WriteErLog(ex.Message); }
finally
{
System.Diagnostics.Process[] CurrentProcess = System.Diagnostics.Process.GetProcessesByName("WINWORD");
for (int i = 0; i < CurrentProcess.Length; i++)
{
if (CurrentProcess[i].MainWindowHandle.ToInt32() == 0)
{
try
{
CurrentProcess[i].Kill();
}
catch
{
}
}
}
}
}
doctest 是image类型的,