用c#怎么把保存在dbf通用字段里的doc文档读出来
发现在直接读出来后 打开乱码,读出来的word比实际的word  大了很多,要经过什么处理吗,实在头疼,请大虾帮忙 

解决方案 »

  1.   

    楼主是用什么方式读取的dbf?
      

  2.   

    http://hi.baidu.com/nofc/blog/item/81fdb95083aabc6584352451.html
      

  3.   

    public override void openFile(object fileName)
            {
                try
                {
                    if (app.Documents.Count > 0)
                    {
                        if (MessageBox.Show("已经打开了一个word文档,你想关闭重新打开该文档吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            object unknow = Type.Missing;
                            doc = app.ActiveDocument;
                            if (MessageBox.Show("你想保存吗?", "保存", MessageBoxButtons.YesNo) == DialogResult.Yes)
                            {
                                app.ActiveDocument.Save();
                            }                        app.ActiveDocument.Close(ref unknow, ref unknow, ref unknow);
                            app.Visible = false;
                        }
                        else
                        {
                            return;
                        }
                    }
                }
                catch (Exception)
                {
                    //MessageBox.Show("您可能关闭了文档");
                    app = new Microsoft.Office.Interop.Word.Application();
                }            try
                {
                    object unknow = Type.Missing;
                    app.Visible = true;
                    doc = app.Documents.Open(ref fileName,
                                             ref unknow, ref unknow, ref unknow, ref unknow, ref unknow,
                                             ref unknow, ref unknow, ref unknow, ref unknow, ref unknow,
                                             ref unknow, ref unknow, ref unknow, ref unknow, ref unknow);
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show("出现错误:" + ex.ToString());
                 }   
               
            }
    public override object readPar(int i)
            {
                try
                {
                    string temp = doc.Paragraphs[i].Range.Text.Trim();
                    return temp;
                }
                catch (Exception e) {
                    MessageBox.Show("Error:"+e.ToString());
                    return null;
                }
            }public override int getParCount()
            {
                return doc.Paragraphs.Count;
            }public override void closeFile()
            {
                try
                {
                    object unknow = Type.Missing;
                    object saveChanges = Word.WdSaveOptions.wdPromptToSaveChanges;
                    app.ActiveDocument.Close(ref saveChanges, ref unknow, ref unknow);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error:" + ex.ToString());
                }
            }public override void quit()
            {
                try
                {
                    object unknow = Type.Missing;
                    object saveChanges = Word.WdSaveOptions.wdSaveChanges;
                    app.Quit(ref saveChanges, ref unknow, ref unknow);
                }
                catch (Exception)
                {            }
            }public void replaceChar() {
                try
                {
                    object replaceAll = Word.WdReplace.wdReplaceAll;
                    object missing = Type.Missing;                app.Selection.Find.ClearFormatting();
                    app.Selection.Find.Text = "^l";                app.Selection.Find.Replacement.ClearFormatting();
                    app.Selection.Find.Replacement.Text = "^p";                app.Selection.Find.Execute(
                        ref missing, ref missing, ref missing, ref missing, ref missing,
                        ref missing, ref missing, ref missing, ref missing, ref missing,
                        ref replaceAll, ref missing, ref missing, ref missing, ref missing);
                }
                catch (Exception e)
                {
                    MessageBox.Show("文档出现错误,请重新操作");
                }
            }
      

  4.   

    liherun  老兄  你贴出来的代码  是 什么啊 操作 word 的 吧 牛马 不相及
      

  5.   

    下面是我程序里面的 vb net 读取dbf部分代码:    '定义dbf数据库字符串
        Public Function dbfdb(ByVal p_storecode As String)
            Dim _dbfdb As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Dir & p_storecode & ";Extended Properties=dBASE IV;User ID=Admin;Password=;"
            Return _dbfdb
        End Function
      

  6.   

    用 命令参数 
    再将命令参数的值写入.doc文件,然后打开