c# 操作word中的表格 批量复制和批量插入

这篇具有很好参考价值的文章主要介绍了c# 操作word中的表格 批量复制和批量插入。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

用的是windows自带的dll包,没有引用第三方

1 WordHelper.cs

using System;
using Microsoft.Office.Interop.Word;
using System.Runtime.InteropServices;

namespace cadWord
{
    public class WordHelper
    {
        private Microsoft.Office.Interop.Word.Document wDoc = null;
        private Microsoft.Office.Interop.Word.Application wApp = null;
        public Microsoft.Office.Interop.Word.Document Document
        {
            get { return wDoc; }
            set { wDoc = value; }
        }

        public Microsoft.Office.Interop.Word.Application Application
        {
            get { return wApp; }
            set { wApp = value; }
        }
        /// <summary>
        /// 打开指定WORD文档
        /// </summary>
        /// <param name="strFileName"></param>
        public void Open(string strFileName)
        {
            wApp = new Microsoft.Office.Interop.Word.ApplicationClass();
            object fileName = strFileName;
            object readOnly = false;
            object isVisible = true;
            object missing = Type.Missing;
            wDoc = wApp.Documents.Open(ref fileName, ref missing, ref readOnly,
                ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
                ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);

            wDoc.Activate();
        }

        #region 从模板创建新的Word文档
        /// <summary>  
        /// 从模板创建新的Word文档  
        /// </summary>  
        /// <param name="templateName">模板文件名</param>  
        /// <returns></returns>  
        public bool CreateNewWordDocument(string templateName)
        {
            try
            {
                return CreateNewWordDocument(templateName, ref wDoc, ref wApp);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion

        #region 从模板创建新的Word文档,并且返回对象Document,Application
        /// <summary>  
        /// 从模板创建新的Word文档,  
        /// </summary>  
        /// <param name="templateName">模板文件名</param>  
        /// <param name="wDoc">返回的Word.Document对象</param>  
        /// <param name="WApp">返回的Word.Application对象</param>  
        /// <returns></returns>  
        public static bool CreateNewWordDocument(string templateName, ref Microsoft.Office.Interop.Word.Document wDoc, ref  Microsoft.Office.Interop.Word.Application WApp)
        {
            Microsoft.Office.Interop.Word.Document thisDocument = null;
            Microsoft.Office.Interop.Word.Application thisApplication = new Microsoft.Office.Interop.Word.Application();/
            thisApplication.Visible = false;
            thisApplication.Caption = "";
            thisApplication.Options.CheckSpellingAsYouType = false;
            thisApplication.Options.CheckGrammarAsYouType = false;

            Object Template = templateName;// Optional Object. The name of the template to be used for the new document. If this argument is omitted, the Normal template is used.  
            Object NewTemplate = false;// Optional Object. True to open the document as a template. The default value is False.  
            Object DocumentType = Microsoft.Office.Interop.Word.WdNewDocumentType.wdNewBlankDocument; // Optional Object. Can be one of the following WdNewDocumentType constants: wdNewBlankDocument, wdNewEmailMessage, wdNewFrameset, or wdNewWebPage. The default constant is wdNewBlankDocument.  
            Object Visible = true;//Optional Object. True to open the document in a visible window. If this value is False, Microsoft Word opens the document but sets the Visible property of the document window to False. The default value is True.  

            try
            {
                Microsoft.Office.Interop.Word.Document wordDoc = thisApplication.Documents.Add(ref Template, ref NewTemplate, ref DocumentType, ref Visible);

                thisDocument = wordDoc;
                wDoc = wordDoc;
                WApp = thisApplication;
                return true;
            }
            catch (Exception ex)
            {
                string err = string.Format("创建Word文档出错,错误原因:{0}", ex.Message);
                throw new Exception(err, ex);
            }
        }
        #endregion

        #region 文档另存为其他文件名
        /// <summary>  
        /// 文档另存为其他文件名  
        /// </summary>  
        /// <param name="fileName">文件名</param>  
        /// <param name="wDoc">Document对象</param>  
        public bool SaveAs(string fileName)
        {
            try
            {
                return SaveAs(fileName, wDoc);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion

        #region 文档另存为其他文件名
        /// <summary>  
        /// 文档另存为其他文件名  
        /// </summary>  
        /// <param name="fileName">文件名</param>  
        /// <param name="wDoc">Document对象</param>  
        public static bool SaveAs(string fileName, Microsoft.Office.Interop.Word.Document wDoc)
        {
            Object FileName = fileName; // 文档的名称。默认值是当前文件夹名和文件名。如果文档在以前没有保存过,则使用默认名称(例如,Doc1.doc)。如果已经存在具有指定文件名的文档,则会在不先提示用户的情况下改写文档。  
            Object FileFormat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocument; // 文档的保存格式。可以是任何 WdSaveFormat 值。要以另一种格式保存文档,请为 SaveFormat 属性指定适当的值。  
            Object LockComments = false; // 如果为 true,则锁定文档以进行注释。默认值为 false。  
            Object Password = System.Type.Missing; // 用来打开文档的密码字符串。(请参见下面的备注。)  
            Object AddToRecentFiles = false; // 如果为 true,则将该文档添加到“文件”菜单上最近使用的文件列表中。默认值为 true。  
            Object WritePassword = System.Type.Missing; // 用来保存对文件所做更改的密码字符串。(请参见下面的备注。)  
            Object ReadOnlyRecommended = false; // 如果为 true,则让 Microsoft Office Word 在打开文档时建议只读状态。默认值为 false。  
            Object EmbedTrueTypeFonts = false; //如果为 true,则将 TrueType 字体随文档一起保存。如果省略的话,则 EmbedTrueTypeFonts 参数假定 EmbedTrueTypeFonts 属性的值。  
            Object SaveNativePictureFormat = true; // 如果图形是从另一个平台(例如,Macintosh)导入的,则 true 表示仅保存导入图形的 Windows 版本。  
            Object SaveFormsData = false; // 如果为 true,则将用户在窗体中输入的数据另存为数据记录。  
            Object SaveAsAOCELetter = false; // 如果文档附加了邮件程序,则 true 表示会将文档另存为 AOCE 信函(邮件程序会进行保存)。  
            Object Encoding = System.Type.Missing; // MsoEncoding。要用于另存为编码文本文件的文档的代码页或字符集。默认值是系统代码页。  
            Object InsertLineBreaks = true; // 如果文档另存为文本文件,则 true 表示在每行文本末尾插入分行符。  
            Object AllowSubstitutions = false; //如果文档另存为文本文件,则 true 允许 Word 将某些符号替换为外观与之类似的文本。例如,将版权符号显示为 (c)。默认值为 false。  
            Object LineEnding = Microsoft.Office.Interop.Word.WdLineEndingType.wdCRLF;// Word 在另存为文本文件的文档中标记分行符和换段符。可以是任何 WdLineEndingType 值。  
            Object AddBiDiMarks = true;//如果为 true,则向输出文件添加控制字符,以便保留原始文档中文本的双向布局。  
            try
            {
                wDoc.SaveAs(ref FileName, ref FileFormat, ref LockComments, ref Password, ref AddToRecentFiles, ref WritePassword
                        , ref ReadOnlyRecommended, ref EmbedTrueTypeFonts, ref SaveNativePictureFormat
                        , ref SaveFormsData, ref SaveAsAOCELetter, ref Encoding, ref InsertLineBreaks, ref AllowSubstitutions
                        , ref LineEnding, ref AddBiDiMarks);
                return true;

            }
            catch (Exception ex)
            {
                string err = string.Format("另存文件出错,错误原因:{0}", ex.Message);
                throw new Exception(err, ex);
            }
        }
        #endregion

        #region 关闭文档
        /// <summary>  
        /// 关闭文档  
        /// </summary>  
        public void Close()
        {
            Close(wDoc, wApp);
            wDoc = null;
            wApp = null;
        }
        #endregion
        [DllImport("shell32.dll ")]
        public static extern int ShellExecute(IntPtr hwnd, String lpszOp, String lpszFile, String lpszParams, String lpszDir, int FsShowCmd);
        #region 关闭文档
        /// <summary>  
        /// 关闭文档  
        /// </summary>  
        /// <param name="wDoc">Document对象</param>  
        /// <param name="WApp">Application对象</param>  
        public static void Close(Microsoft.Office.Interop.Word.Document wDoc, Microsoft.Office.Interop.Word.Application WApp)
        {

            Object SaveChanges = Microsoft.Office.Interop.Word.WdSaveOptions.wdSaveChanges;// 指定文档的保存操作。可以是下列 WdSaveOptions 值之一:wdDoNotSaveChanges、wdPromptToSaveChanges 或 wdSaveChanges。  
            Object OriginalFormat = Microsoft.Office.Interop.Word.WdOriginalFormat.wdOriginalDocumentFormat;// 指定文档的保存格式。可以是下列 WdOriginalFormat 值之一:wdOriginalDocumentFormat、wdPromptUser 或 wdWordDocument。  
            Object RouteDocument = false;// 如果为 true,则将文档传送给下一个收件人。如果没有为文档附加传送名单,则忽略此参数。  
            try
            {
                if (wDoc != null) wDoc.Close(ref SaveChanges, ref OriginalFormat, ref RouteDocument);
                if (WApp != null) WApp.Quit(ref SaveChanges, ref OriginalFormat, ref RouteDocument);

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        #endregion

        #region 填充书签
        /// <summary>  
        /// 填充书签  
        /// </summary>  
        /// <param name="bookmark">书签</param>  
        /// <param name="value">值</param>  
        public void Replace(string bookmark, string value)
        {
            try
            {
                object bkObj = bookmark;
                if (wApp.ActiveDocument.Bookmarks.Exists(bookmark) == true)
                {
                    wApp.ActiveDocument.Bookmarks.get_Item(ref bkObj).Select();
                }
                else return;
                wApp.Selection.TypeText(value);

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion

        public bool FindTable(string bookmarkTable)
        {
            try
            {
                object bkObj = bookmarkTable;
                if (wApp.ActiveDocument.Bookmarks.Exists(bookmarkTable) == true)
                {
                    wApp.ActiveDocument.Bookmarks.get_Item(ref bkObj).Select();
                    return true;
                }
                else
                    return false;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public void MoveNextCell()
        {
            try
            {
                Object unit = Microsoft.Office.Interop.Word.WdUnits.wdCell;
                Object count = 1;
                wApp.Selection.Move(ref unit, ref count);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public void tableInsertRows(int i, int j, int count, int k)
        {
            Microsoft.Office.Interop.Word.Table newTable = wDoc.Tables[k];
            for (int jj = 0; jj < count; jj++)
            {
                object beforeRow = newTable.Cell(i, j).Range;
                newTable.Rows.Add(ref beforeRow);
            }
        }

        public void SetWordCellValue(int i, int j, int k, string value)
        {
            try
            {
                Microsoft.Office.Interop.Word.Table newTable = wDoc.Tables[k];
                newTable.Cell(i, j).Range.Text = value;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 插入图片
        /// </summary>
        /// <param name="i"></param>
        /// <param name="j"></param>
        /// <param name="k"></param>
        /// <param name="strPicPath"></param>
        public void InsertImage(int i, int j, int k, string strPicPath)
        {
            Microsoft.Office.Interop.Word.Table newTable = wDoc.Tables[k];
            string FileName = strPicPath;
            object LinkToFile = false;
            object SaveWithDocument = true;
            object Anchor = newTable.Cell(i, j).Range;
            wApp.ActiveDocument.InlineShapes.AddPicture(FileName, ref LinkToFile, ref SaveWithDocument, ref Anchor).Select();

        }

        public void SetCellValue(string value)
        {
            try
            {
                wApp.Selection.Rows.Alignment = WdRowAlignment.wdAlignRowCenter;
                wApp.Selection.TypeText(value);
                wApp.Selection.Rows.Alignment = WdRowAlignment.wdAlignRowCenter;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public string GetCellValue()
        {
            try
            {

                string value = wApp.Selection.Text;
                if (value.Length <= 2)
                {

                    return "";
                }
                else
                    return value;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public void MoveNextRow()
        {
            try
            {
                Object extend = Microsoft.Office.Interop.Word.WdMovementType.wdExtend;
                Object unit = Microsoft.Office.Interop.Word.WdUnits.wdCell;
                Object count = 1;
                wApp.Selection.MoveRight(ref unit, ref count, ref extend);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        //获取word文件的文本内容
        public string DocToText(string docFileName, out Font xx)
        {
            //实例化COM        
            Application Word_App = new Application();/
            object fileobj = docFileName;
            object nullobj = System.Reflection.Missing.Value;//打开指定文件(不同版本的COM参数个数有差异,
            //一般而言除第一个外都用nullobj就行了)


            Document wd = Word_App.Documents.Open(ref fileobj, ref nullobj, ref nullobj, ref nullobj,
                                                    ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj,
                                                    ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj,
                                                    ref nullobj, ref nullobj);
            //取得doc文件中的文本内容
            string outText = wd.Content.Text;
            xx = wd.Content.Font;
            //关闭文件
            wd.Close(ref nullobj, ref nullobj, ref nullobj);
            //关闭COM
            Word_App.Quit(ref nullobj, ref nullobj, ref nullobj);
            //返回文本内容
            return outText;
        }



        /// <summary>
        /// 复制模板中已经存放的表,并生成其后位置不定数量的表
        /// </summary>
        /// <param name="_tableIndex">对象表</param>
        /// <param name="_row">表后位置,即计算其行列数也能得出数字</param>
        /// <param name="_tableNum">表数量</param>
        public void copyTableInsert(int _tableIndex, object _row, int _tableNum)
        {
            //--start-#根据表序号索引,获取对象表#-->
            Microsoft.Office.Interop.Word.Table copyTable = wDoc.Tables[_tableIndex];
            //--start-#复制该对象表#-->
            copyTable.Range.Copy();//复制一下
            //--start-#让光标选中该对象表#-->
            copyTable.Select();
            //--start-#不允许表跨页断行#-->
            copyTable.AllowPageBreaks = false;

            object what = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToLine;
            object which = Microsoft.Office.Interop.Word.WdGoToDirection.wdGoToNext;
            object missing = Type.Missing;
            //--start-#让光标移至表后#-->
            wApp.Selection.GoTo(ref what, ref which, ref _row, ref missing);
            //--start-#计算生成的表数量#-->
            for (int i = 0; i < _tableNum; i++)
            {
                //--start-#表后插入分页符#-->
                wApp.Selection.InsertBreak(ref missing);
                //--start-#复制表生成#-->
                wApp.Selection.Paste();
            }










            // Microsoft.Office.Interop.Word.Table copyTable = wDoc.Tables[3];
            // copyTable.Range.Copy();//复制一下
            // copyTable.Select();//选中表对象,此时光标已经在这张表格上了
            // copyTable.AllowPageBreaks = false;

            // //复制后的第一张表:实验室2
            // object what = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToLine;
            // object which = Microsoft.Office.Interop.Word.WdGoToDirection.wdGoToNext;
            // object missing = Type.Missing;

            // //  object count = 36;//光标下移3格
            // wApp.Selection.GoTo(ref what, ref which, ref _row, ref missing);
            // // wApp.Selection.Range.Text = "单体建筑核实比对表2\n";//插入文本
            // wApp.Selection.GoTo(ref what, ref which, 1, ref missing);//光标下移1格,不和被测科室这个文本在一块,另起一行
            // wApp.Selection.Paste();//粘贴表



            // //复制后的第一张表:实验室2

            // //what = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToLine;
            // //which = Microsoft.Office.Interop.Word.WdGoToDirection.wdGoToNext;
             wApp.Selection.Range.Text = "被测科室:实验室2\n";//插入文本

            // wApp.Selection.GoTo(ref what, ref which, 1, ref missing);//光标下移1格,不和被测科室这个文本在一块,另起一行
            // wApp.Selection.Paste();//粘贴表
        }

    }
}

2 核心代码

  /// <summary>
        /// 复制模板中已经存放的表,并生成其后位置不定数量的表
        /// </summary>
        /// <param name="_tableIndex">对象表</param>
        /// <param name="_row">表后位置,即计算其行列数也能得出数字</param>
        /// <param name="_tableNum">表数量</param>
        public void copyTableInsert(int _tableIndex, object _row, int _tableNum)
        {
            //--start-#根据表序号索引,获取对象表#-->
            Microsoft.Office.Interop.Word.Table copyTable = wDoc.Tables[_tableIndex];
            //--start-#复制该对象表#-->
            copyTable.Range.Copy();//复制一下
            //--start-#让光标选中该对象表#-->
            copyTable.Select();
            //--start-#不允许表跨页断行#-->
            copyTable.AllowPageBreaks = false;

            object what = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToLine;
            object which = Microsoft.Office.Interop.Word.WdGoToDirection.wdGoToNext;
            object missing = Type.Missing;
            //--start-#让光标移至表后#-->
            wApp.Selection.GoTo(ref what, ref which, ref _row, ref missing);
            //--start-#计算生成的表数量#-->
            for (int i = 0; i < _tableNum; i++)
            {
                //--start-#表后插入分页符#-->
                wApp.Selection.InsertBreak(ref missing);
                //--start-#复制表生成#-->
                wApp.Selection.Paste();
            }










            // Microsoft.Office.Interop.Word.Table copyTable = wDoc.Tables[3];
            // copyTable.Range.Copy();//复制一下
            // copyTable.Select();//选中表对象,此时光标已经在这张表格上了
            // copyTable.AllowPageBreaks = false;

            // //复制后的第一张表:实验室2
            // object what = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToLine;
            // object which = Microsoft.Office.Interop.Word.WdGoToDirection.wdGoToNext;
            // object missing = Type.Missing;

            // //  object count = 36;//光标下移3格
            // wApp.Selection.GoTo(ref what, ref which, ref _row, ref missing);
            // // wApp.Selection.Range.Text = "单体建筑核实比对表2\n";//插入文本
            // wApp.Selection.GoTo(ref what, ref which, 1, ref missing);//光标下移1格,不和被测科室这个文本在一块,另起一行
            // wApp.Selection.Paste();//粘贴表



            // //复制后的第一张表:实验室2

            // //what = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToLine;
            // //which = Microsoft.Office.Interop.Word.WdGoToDirection.wdGoToNext;
             wApp.Selection.Range.Text = "被测科室:实验室2\n";//插入文本

            // wApp.Selection.GoTo(ref what, ref which, 1, ref missing);//光标下移1格,不和被测科室这个文本在一块,另起一行
            // wApp.Selection.Paste();//粘贴表
        }

3 调用代码

批量插入表格后,原理就是整个文档会从前到后编制表格索引,从一开始意思是前面序号为1.2.3表格,1复制3个在后面,那么原先的2表格序号就标为2+3=5!为表格设置各种值也是按这个序号来!文章来源地址https://www.toymoban.com/news/detail-718006.html

  private void button1_Click(object sender, EventArgs e)
        {
            string mbPath = System.IO.Path.Combine(Application.StartupPath + "\\MB", "测量报告样本.docx");//模板

            string savePath = @"C:\Users\54061\Desktop\333\test\测量报告样本.docx";//保存路径


            //string imagePath = @"C:\Users\54061\Desktop\彭泽军\test\江西省工程有限公司(公章).png";//保存路径
            File.Copy(mbPath, savePath, true);

            WordHelper wordhelper = new WordHelper();
            wordhelper.Open(savePath);

            //--start-#计算生成的表#-->
            wordhelper.copyTableInsert(3, 32, 5);
            wordhelper.copyTableInsert(4 + 5, 4, 5);
            wordhelper.copyTableInsert(5 + 5 + 5, 14, 5);
            //--start-#计算单体建筑核实比对表#-->
         
            wordhelper.Close();
            MessageBox.Show("导出完成!");
        }

到了这里,关于c# 操作word中的表格 批量复制和批量插入的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【Axure教程】中继器表格插入行、复制行和删除行

    表格是展示数据常用的工具,在原型制作时,我们经常会用到插入行和复制行的操作。那作者今天就教大家如何在Axure里用中继器表格制作出以下高保真的交互效果: 插入行:在已选中行的下方插入一行空行 复制行:在已选中行的下方插入一行与已选中行相同内容的行 编辑

    2023年04月09日
    浏览(11)
  • 使用poi-tl向word插入图片、文本、表格行循环

    工作中难免会向word中操作数据,本文主要介绍poi-tl的使用,先来看效果图 核心介绍: 标签 1、插入文本标签 : {{var}} 2、插入图片标签: {{@var}} 操作步骤: 1、引入依赖 2、Java核心代码 官方网址:http://deepoove.com/poi-tl/ 1、准备模版,定义好需要的标签 2、查询模版 3、获取需要填

    2024年02月05日
    浏览(33)
  • 使用 C# 在Word中插入图表

    Word中的图表功能将数据可视化地呈现在文档中。这为展示数据和进行数据分析提供了一种方便且易于使用的工具,使作者能够以直观的方式传达信息。要 通过C#代码来实现在Word中绘制图表 ,可以借助  Spire.Doc for .NET  控件,具体操作参考下文。 C# 在Word中插入柱状图 C# 在

    2024年02月08日
    浏览(14)
  • C# 读取Word表格到DataSet

    目录 功能需求 Office 数据源的一些映射关系 范例运行环境 配置Office DCOM 关键代码 组件库引入 ​核心代码 杀掉进程 总结 在应用项目里,多数情况下我们会遇到导入 Excel 文件数据到数据库的功能需求,但某些情况下,也存在使用 Word 进行表格数据编辑的情况。Word 和 Excel 其

    2024年02月04日
    浏览(14)
  • word文档批量生成工具(附免费软件)(按Excel表格内容自动替换内容生成文档)

    批量生成word文档是让人无比厌恶但有时又不得不做的事情。比如学校要给拟录取的学生发通知书,就可能需要批量生成一批只有“姓名”、“学院”和“专业”不同,其他内容都相同的word文档以供打印(事实上直接生成pdf是更好的选择,这个以后有心情可以弄一下)。 要实

    2024年02月11日
    浏览(22)
  • C# 读取二维数组集合输出到Word预设表格

    目录 应用场景 设计约定 范例运行环境 配置Office DCOM 实现代码 组件库引入 核心代码 DataSet转二维数组 导出写入WORD表格 调用举例 小结 存储或导出个人WORD版简历是招聘应用系统中的常用功能,我们通常会通过应用系统采集用户的个人简历信息到数据库,许多情况下我们会读

    2024年03月23日
    浏览(16)
  • 用python批量实现文件夹中所有pdf转成图片并插入到一个word文件中

    要实现这个任务,你需要使用Python的几个库: PyPDF2  用于处理PDF文件, python-docx  用于操作Word文件, PIL (或 Pillow )用于处理图片。 首先,确保你已经安装了这些库。如果没有,你可以使用pip来安装: bash复制代码 pip install PyPDF2 python-docx Pillow 接下来是Python脚本的示例代码

    2024年01月16日
    浏览(25)
  • ElasticSearch中批量操作(批量查询_mget、批量插入删除_bulk)

    有时候可以通过批量操作来减少网络请求。如:批量查询、批量插入数据。 当某一条数据不存在,不影响整体响应,需要通过found的值进行判断是否查询到数据。          在Elasticsearch中,支持批量的插入、修改、删除操作,都是通过_bulk的api完成的。 请求格式如下:(

    2024年02月12日
    浏览(23)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包