返回顶部
首页 > 资讯 > 精选 >Java中Word怎么利用com进行操作
  • 478
分享到

Java中Word怎么利用com进行操作

javacom组件word 2023-05-31 03:05:31 478人浏览 泡泡鱼
摘要

Java中Word怎么利用com进行操作?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。实例代码如下:import com.jacob.activeX.ActiveXComp

Java中Word怎么利用com进行操作?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

实例代码如下:

import com.jacob.activeX.ActiveXComponent; import com.jacob.com.Dispatch; import com.jacob.com.Variant;  public class WordBean {   // word文档   private Dispatch doc;   // word运行程序对象   private ActiveXComponent word;   // 所有word文档集合   private Dispatch documents;   // 选定的范围或插入点   private Dispatch selection;   private boolean saveOnExit = true;   public WordBean()throws Exception{     if (word == null) {       word = new ActiveXComponent("Word.Application");       word.setProperty("Visible", new Variant(false));  //不可见打开word            word.setProperty("AutomationSecurity", new Variant(3)); //禁用宏     }     if (documents == null)       documents = word.getProperty("Documents").toDispatch();   }      public void setSaveOnExit(boolean saveOnExit) {     this.saveOnExit = saveOnExit;   }      public void createNewDocument() {     doc = Dispatch.call(documents, "Add").toDispatch();     selection = Dispatch.get(word, "Selection").toDispatch();   }      public void openDocument(String docPath) {     closeDocument();     doc = Dispatch.call(documents, "Open", docPath).toDispatch();     selection = Dispatch.get(word, "Selection").toDispatch();   }      public void openDocumentOnlyRead(String docPath, String pwd)throws Exception {     closeDocument(); //   doc = Dispatch.invoke(documents, "Open", Dispatch.Method,  //       new Object[]{docPath, new Variant(false), new Variant(true), new Variant(true), pwd},  //       new int[1]).toDispatch();//打开word文件      doc = Dispatch.callN(documents, "Open", new Object[]{docPath, new Variant(false),          new Variant(true), new Variant(true), pwd, "", new Variant(false)}).toDispatch();     selection = Dispatch.get(word, "Selection").toDispatch();   }   public void openDocument(String docPath, String pwd)throws Exception {     closeDocument();         doc = Dispatch.callN(documents, "Open", new Object[]{docPath, new Variant(false),          new Variant(false), new Variant(true), pwd}).toDispatch();     selection = Dispatch.get(word, "Selection").toDispatch();   }      public void moveUp(int pos) {     if (selection == null)       selection = Dispatch.get(word, "Selection").toDispatch();     for (int i = 0; i < pos; i++)       Dispatch.call(selection, "MoveUp");   }      public void moveDown(int pos) {     if (selection == null)       selection = Dispatch.get(word, "Selection").toDispatch();     for (int i = 0; i < pos; i++)       Dispatch.call(selection, "MoveDown");   }      public void moveLeft(int pos) {     if (selection == null)       selection = Dispatch.get(word, "Selection").toDispatch();     for (int i = 0; i < pos; i++) {       Dispatch.call(selection, "MoveLeft");     }   }      public void moveRight(int pos) {     if (selection == null)       selection = Dispatch.get(word, "Selection").toDispatch();     for (int i = 0; i < pos; i++)       Dispatch.call(selection, "MoveRight");   }      public void moveStart() {     if (selection == null)       selection = Dispatch.get(word, "Selection").toDispatch();     Dispatch.call(selection, "HomeKey", new Variant(6));   }      @SuppressWarnings("static-access")   public boolean find(String toFindText) {     if (toFindText == null || toFindText.equals(""))       return false;     // 从selection所在位置开始查询     Dispatch find = word.call(selection, "Find").toDispatch();     // 设置要查找的内容     Dispatch.put(find, "Text", toFindText);     // 向前查找     Dispatch.put(find, "Forward", "True");     // 设置格式     Dispatch.put(find, "FORMat", "True");     // 大小写匹配     Dispatch.put(find, "MatchCase", "True");     // 全字匹配     Dispatch.put(find, "MatchWholeWord", "True");     // 查找并选中     return Dispatch.call(find, "Execute").getBoolean();   }      public boolean replaceText(String toFindText, String newText) {     if (!find(toFindText))       return false;     Dispatch.put(selection, "Text", newText);     return true;   }      public void replaceAllText(String toFindText, String newText) {     while (find(toFindText)) {       Dispatch.put(selection, "Text", newText);       Dispatch.call(selection, "MoveRight");     }   }      public void insertText(String newText) {     Dispatch.put(selection, "Text", newText);   }      public boolean replaceImage(String toFindText, String imagePath) {     if (!find(toFindText))       return false;     Dispatch.call(Dispatch.get(selection, "InLineShapes").toDispatch(),         "AddPicture", imagePath);     return true;   }      public void replaceAllImage(String toFindText, String imagePath) {     while (find(toFindText)) {       Dispatch.call(Dispatch.get(selection, "InLineShapes").toDispatch(),           "AddPicture", imagePath);       Dispatch.call(selection, "MoveRight");     }   }      public void insertImage(String imagePath) {     Dispatch.call(Dispatch.get(selection, "InLineShapes").toDispatch(),         "AddPicture", imagePath);   }      public void mergeCell(int tableIndex, int fstCellRowIdx, int fstCellColIdx,       int secCellRowIdx, int secCellColIdx) {     // 所有表格     Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();     // 要填充的表格     Dispatch table = Dispatch.call(tables, "Item", new Variant(tableIndex))         .toDispatch();     Dispatch fstCell = Dispatch.call(table, "Cell",         new Variant(fstCellRowIdx), new Variant(fstCellColIdx))         .toDispatch();     Dispatch secCell = Dispatch.call(table, "Cell",         new Variant(secCellRowIdx), new Variant(secCellColIdx))         .toDispatch();     Dispatch.call(fstCell, "Merge", secCell);   }      public void putTxtToCell(int tableIndex, int cellRowIdx, int cellColIdx,       String txt) {     // 所有表格     Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();     // 要填充的表格     Dispatch table = Dispatch.call(tables, "Item", new Variant(tableIndex))         .toDispatch();     Dispatch cell = Dispatch.call(table, "Cell", new Variant(cellRowIdx),         new Variant(cellColIdx)).toDispatch();     Dispatch.call(cell, "Select");     Dispatch.put(selection, "Text", txt);       }      public String getTxtFromCell(int tableIndex, int cellRowIdx, int cellColIdx) {     // 所有表格     Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();     // 要填充的表格     Dispatch table = Dispatch.call(tables, "Item", new Variant(tableIndex))         .toDispatch();     Dispatch cell = Dispatch.call(table, "Cell", new Variant(cellRowIdx),         new Variant(cellColIdx)).toDispatch();     Dispatch.call(cell, "Select");      String ret = "";       ret = Dispatch.get(selection, "Text").toString();     ret = ret.substring(0, ret.length()-1); //去掉最后的回车符;     return ret;   }      public void pasteexcelSheet(String pos) {     moveStart();     if (this.find(pos)) {       Dispatch textRange = Dispatch.get(selection, "Range").toDispatch();       Dispatch.call(textRange, "Paste");     }   }      public void copyTable(String pos, int tableIndex) {     // 所有表格     Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();     // 要填充的表格     Dispatch table = Dispatch.call(tables, "Item", new Variant(tableIndex))         .toDispatch();     Dispatch range = Dispatch.get(table, "Range").toDispatch();     Dispatch.call(range, "Copy");     if (this.find(pos)) {       Dispatch textRange = Dispatch.get(selection, "Range").toDispatch();       Dispatch.call(textRange, "Paste");     }   }      public void copyTableFromAnotherDoc(String anotherDocPath, int tableIndex,       String pos) {     Dispatch doc2 = null;     try {       doc2 = Dispatch.call(documents, "Open", anotherDocPath)           .toDispatch();       // 所有表格       Dispatch tables = Dispatch.get(doc2, "Tables").toDispatch();       // 要填充的表格       Dispatch table = Dispatch.call(tables, "Item",           new Variant(tableIndex)).toDispatch();       Dispatch range = Dispatch.get(table, "Range").toDispatch();       Dispatch.call(range, "Copy");       if (this.find(pos)) {         Dispatch textRange = Dispatch.get(selection, "Range")             .toDispatch();         Dispatch.call(textRange, "Paste");       }     } catch (Exception e) {       e.printStackTrace();     } finally {       if (doc2 != null) {         Dispatch.call(doc2, "Close", new Variant(saveOnExit));         doc2 = null;       }     }   }      public void copyImageFromAnotherDoc(String anotherDocPath, int shapeIndex,       String pos) {     Dispatch doc2 = null;     try {       doc2 = Dispatch.call(documents, "Open", anotherDocPath)           .toDispatch();       Dispatch shapes = Dispatch.get(doc2, "InLineShapes").toDispatch();       Dispatch shape = Dispatch.call(shapes, "Item",           new Variant(shapeIndex)).toDispatch();       Dispatch imageRange = Dispatch.get(shape, "Range").toDispatch();       Dispatch.call(imageRange, "Copy");       if (this.find(pos)) {         Dispatch textRange = Dispatch.get(selection, "Range")             .toDispatch();         Dispatch.call(textRange, "Paste");       }     } catch (Exception e) {       e.printStackTrace();     } finally {       if (doc2 != null) {         Dispatch.call(doc2, "Close", new Variant(saveOnExit));         doc2 = null;       }     }   }      public void createTable(String pos, int numCols, int numRows) {     if (find(pos)) {       Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();       Dispatch range = Dispatch.get(selection, "Range").toDispatch();       @SuppressWarnings("unused")       Dispatch newTable = Dispatch.call(tables, "Add", range,           new Variant(numRows), new Variant(numCols)).toDispatch();       Dispatch.call(selection, "MoveRight");     } else {       Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();       Dispatch range = Dispatch.get(selection, "Range").toDispatch();       @SuppressWarnings("unused")       Dispatch newTable = Dispatch.call(tables, "Add", range,           new Variant(numRows), new Variant(numCols)).toDispatch();       Dispatch.call(selection, "MoveRight");     }   }      public void addTableRow(int tableIndex, int rowIndex) {     // 所有表格     Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();     // 要填充的表格     Dispatch table = Dispatch.call(tables, "Item", new Variant(tableIndex))         .toDispatch();     // 表格的所有行     Dispatch rows = Dispatch.get(table, "Rows").toDispatch();     Dispatch row = Dispatch.call(rows, "Item", new Variant(rowIndex))         .toDispatch();     Dispatch.call(rows, "Add", new Variant(row));   }      public void addFirstTableRow(int tableIndex) {     // 所有表格     Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();     // 要填充的表格     Dispatch table = Dispatch.call(tables, "Item", new Variant(tableIndex))         .toDispatch();     // 表格的所有行     Dispatch rows = Dispatch.get(table, "Rows").toDispatch();     Dispatch row = Dispatch.get(rows, "First").toDispatch();     Dispatch.call(rows, "Add", new Variant(row));   }      public void addLastTableRow(int tableIndex) {     // 所有表格     Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();     // 要填充的表格     Dispatch table = Dispatch.call(tables, "Item", new Variant(tableIndex))         .toDispatch();     // 表格的所有行     Dispatch rows = Dispatch.get(table, "Rows").toDispatch();     Dispatch row = Dispatch.get(rows, "Last").toDispatch();     Dispatch.call(rows, "Add", new Variant(row));   }      public void addRow(int tableIndex) {     Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();     // 要填充的表格     Dispatch table = Dispatch.call(tables, "Item", new Variant(tableIndex))         .toDispatch();     // 表格的所有行     Dispatch rows = Dispatch.get(table, "Rows").toDispatch();     Dispatch.call(rows, "Add");   }      public void addCol(int tableIndex) {     // 所有表格     Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();     // 要填充的表格     Dispatch table = Dispatch.call(tables, "Item", new Variant(tableIndex))         .toDispatch();     // 表格的所有行     Dispatch cols = Dispatch.get(table, "Columns").toDispatch();     Dispatch.call(cols, "Add").toDispatch();     Dispatch.call(cols, "AutoFit");   }      public void addTableCol(int tableIndex, int colIndex) {     // 所有表格     Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();     // 要填充的表格     Dispatch table = Dispatch.call(tables, "Item", new Variant(tableIndex))         .toDispatch();     // 表格的所有行     Dispatch cols = Dispatch.get(table, "Columns").toDispatch();     System.out.println(Dispatch.get(cols, "Count"));     Dispatch col = Dispatch.call(cols, "Item", new Variant(colIndex))         .toDispatch();     // Dispatch col = Dispatch.get(cols, "First").toDispatch();     Dispatch.call(cols, "Add", col).toDispatch();     Dispatch.call(cols, "AutoFit");   }      public void addFirstTableCol(int tableIndex) {     Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();     // 要填充的表格     Dispatch table = Dispatch.call(tables, "Item", new Variant(tableIndex))         .toDispatch();     // 表格的所有行     Dispatch cols = Dispatch.get(table, "Columns").toDispatch();     Dispatch col = Dispatch.get(cols, "First").toDispatch();     Dispatch.call(cols, "Add", col).toDispatch();     Dispatch.call(cols, "AutoFit");   }      public void addLastTableCol(int tableIndex) {     Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();     // 要填充的表格     Dispatch table = Dispatch.call(tables, "Item", new Variant(tableIndex))         .toDispatch();     // 表格的所有行     Dispatch cols = Dispatch.get(table, "Columns").toDispatch();     Dispatch col = Dispatch.get(cols, "Last").toDispatch();     Dispatch.call(cols, "Add", col).toDispatch();     Dispatch.call(cols, "AutoFit");   }      @SuppressWarnings("deprecation")   public void autoFitTable() {     Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();     int count = Dispatch.get(tables, "Count").toInt();     for (int i = 0; i < count; i++) {       Dispatch table = Dispatch.call(tables, "Item", new Variant(i + 1))           .toDispatch();       Dispatch cols = Dispatch.get(table, "Columns").toDispatch();       Dispatch.call(cols, "AutoFit");     }   }      @SuppressWarnings("deprecation")   public void callWordMacro() {     Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();     int count = Dispatch.get(tables, "Count").toInt();     Variant vMacroName = new Variant("Normal.NewMacros.tableFit");     @SuppressWarnings("unused")     Variant vParam = new Variant("param1");     @SuppressWarnings("unused")     Variant para[] = new Variant[] { vMacroName };     for (int i = 0; i < count; i++) {       Dispatch table = Dispatch.call(tables, "Item", new Variant(i + 1))           .toDispatch();       Dispatch.call(table, "Select");       Dispatch.call(word, "Run", "tableFitContent");     }   }      public void setFont(boolean bold, boolean italic, boolean underLine,       String colorSize, String size, String name) {     Dispatch font = Dispatch.get(selection, "Font").toDispatch();     Dispatch.put(font, "Name", new Variant(name));     Dispatch.put(font, "Bold", new Variant(bold));     Dispatch.put(font, "Italic", new Variant(italic));     Dispatch.put(font, "Underline", new Variant(underLine));     Dispatch.put(font, "Color", colorSize);     Dispatch.put(font, "Size", size);   }      public void setTableCellSelected(int tableIndex, int cellRowIdx, int cellColIdx){     Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();     Dispatch table = Dispatch.call(tables, "Item", new Variant(tableIndex))         .toDispatch();     Dispatch cell = Dispatch.call(table, "Cell", new Variant(cellRowIdx),         new Variant(cellColIdx)).toDispatch();     Dispatch.call(cell, "Select");   }      public void setCellVerticalAlign(int verticalAlign){     Dispatch cells = Dispatch.get(selection, "Cells").toDispatch();        Dispatch.put(cells, "VerticalAlignment", new Variant(verticalAlign));       }      @SuppressWarnings("deprecation")   public void setApplyTableFormat(){     Dispatch tables = Dispatch.get(doc, "Tables").toDispatch();     int tabCount = Integer.valueOf(Dispatch.get(tables, "Count").toString());  //System.out.println(tabCount);     System.out.println("*******************************************************");     for(int i=1; i<=tabCount; i++){          Dispatch table = Dispatch.call(tables, "Item", new Variant(i)).toDispatch();       Dispatch rows = Dispatch.get(table, "Rows").toDispatch();               if(i==1){         Dispatch.put(rows, "Alignment", new Variant(2));  //1-居中,2-Right         continue ;       }       Dispatch.put(rows, "Alignment", new Variant(1));  //1-居中            Dispatch.call(table, "AutoFitBehavior", new Variant(1));//设置自动调整表格方式,1-根据窗口自动调整       Dispatch.put(table, "PreferredWidthType", new Variant(1));       Dispatch.put(table, "PreferredWidth", new Variant(700));             System.out.println(Dispatch.get(rows, "HeightRule").toString());       Dispatch.put(rows, "HeightRule", new Variant(1));  //0-自动wdRowHeightAuto,1-最小值wdRowHeightAtLeast, 2-固定wdRowHeightExactly         Dispatch.put(rows, "Height", new Variant(0.04*28.35));            //int oldAlign = Integer.valueOf(Dispatch.get(rows, "Alignment").toString());         //System.out.println("Algin:" + oldAlign);     }     }      public void setParagraphsProperties(int alignment, int lineSpaceingRule,       int lineUnitBefore, int lineUnitAfter, int characterUnitFirstLineIndent){     Dispatch paragraphs = Dispatch.get(selection, "Paragraphs").toDispatch();       Dispatch.put(paragraphs, "Alignment", new Variant(alignment));       //对齐方式          Dispatch.put(paragraphs, "LineSpacingRule", new Variant(lineSpaceingRule)); //行距     Dispatch.put(paragraphs, "LineUnitBefore", new Variant(lineUnitBefore));  //段前     Dispatch.put(paragraphs, "LineUnitAfter", new Variant(lineUnitAfter));   //段后       Dispatch.put(paragraphs, "CharacterUnitFirstLineIndent",          new Variant(characterUnitFirstLineIndent));             //首行缩进字符数   }        public void getParagraphsProperties(){     Dispatch paragraphs = Dispatch.get(selection, "Paragraphs").toDispatch();         String val = Dispatch.get(paragraphs, "LineSpacingRule").toString();  //行距     val = Dispatch.get(paragraphs, "Alignment").toString();     //对齐方式      val = Dispatch.get(paragraphs, "LineUnitBefore").toString();  //段前行数     val = Dispatch.get(paragraphs, "LineUnitAfter").toString();   //段后行数     val = Dispatch.get(paragraphs, "FirstLineIndent").toString();  //首行缩进     val = Dispatch.get(paragraphs, "CharacterUnitFirstLineIndent").toString(); //首行缩进字符数   }      public void save(String savePath) {     Dispatch.call(Dispatch.call(word, "WordBasic").getDispatch(),         "FileSaveAs", savePath);   }        public void saveAshtml(String htmlPath){     Dispatch.invoke(doc,"SaveAs", Dispatch.Method,          new Object[]{htmlPath, new Variant(8)}, new int[1]);    }      public void closeDocument(int val) {     Dispatch.call(doc, "Close", new Variant(val));     doc = null;   }      public void closeDocument() {     if (doc != null) {       Dispatch.call(doc, "Save");       Dispatch.call(doc, "Close", new Variant(saveOnExit));       doc = null;     }   }   public void closeDocumentWithoutSave(){     if (doc != null) {            Dispatch.call(doc, "Close", new Variant(false));       doc = null;     }   }      public void close() {     //closeDocument();     if (word != null) {       Dispatch.call(word, "Quit");       word = null;     }     selection = null;     documents = null;   }      public void printFile() {     if (doc != null) {       Dispatch.call(doc, "PrintOut");     }   }      public void protectedWord(String pwd){     String protectionType = Dispatch.get(doc, "ProtectionType").toString();     if(protectionType.equals("-1")){         Dispatch.call(doc, "Protect", new Variant(3), new Variant(true), pwd);     }     }      public void unProtectedWord(String pwd){     String protectionType = Dispatch.get(doc, "ProtectionType").toString();     if(protectionType.equals("3")){        Dispatch.call(doc, "Unprotect", pwd);     }   }      public void setAutomationSecurity(int value){     word.setProperty("AutomationSecurity", new Variant(value));    }      public String getParagraphs(int paragraphsIndex){     String ret = "";     Dispatch paragraphs = Dispatch.get(doc, "Paragraphs").toDispatch(); // 所有段落     int paragraphCount = Dispatch.get(paragraphs, "Count").getInt();      // 一共的段落数     Dispatch paragraph = null;     Dispatch range = null;     if(paragraphCount > paragraphsIndex && 0 < paragraphsIndex){        paragraph = Dispatch.call(paragraphs, "Item", new Variant(paragraphsIndex)).toDispatch();       range = Dispatch.get(paragraph, "Range").toDispatch();       ret = Dispatch.get(range, "Text").toString();     }       return ret;   }      public void setHeaderContent(String cont){     Dispatch activeWindow = Dispatch.get(doc, "ActiveWindow").toDispatch();     Dispatch view = Dispatch.get(activeWindow, "View").toDispatch();     //Dispatch seekView = Dispatch.get(view, "SeekView").toDispatch();     Dispatch.put(view, "SeekView", new Variant(9));     //wdSeekCurrentPageHeader-9           Dispatch headerFooter = Dispatch.get(selection, "HeaderFooter").toDispatch();     Dispatch range = Dispatch.get(headerFooter, "Range").toDispatch();     Dispatch.put(range, "Text", new Variant(cont));      //String content = Dispatch.get(range, "Text").toString();     Dispatch font = Dispatch.get(range, "Font").toDispatch();           Dispatch.put(font, "Name", new Variant("楷体_GB2312"));     Dispatch.put(font, "Bold", new Variant(true));     //Dispatch.put(font, "Italic", new Variant(true));     //Dispatch.put(font, "Underline", new Variant(true));     Dispatch.put(font, "Size", 9);     Dispatch.put(view, "SeekView", new Variant(0));     //wdSeekMainDocument-0恢复视图;   }   public static void main(String[] args)throws Exception{     WordBean word = new WordBean();      word.openDocument("D:/竞价平台.doc");     word.setHeaderContent("*****************88设置页眉内容11111111111111111!");     //word.unProtectedWord("1qaz");     //word.protectedWord("123");     System.out.print(word.getParagraphs(3));     word.closeDocument();     word.close();   } }

--结束END--

本文标题: Java中Word怎么利用com进行操作

本文链接: https://lsjlt.com/news/223170.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
  • Java中Word怎么利用com进行操作
    Java中Word怎么利用com进行操作?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。实例代码如下:import com.jacob.activeX.ActiveXComp...
    99+
    2023-05-31
    java com组件 word
  • HDFS怎么利用JAVA进行操作
    这篇文章给大家介绍HDFS怎么利用JAVA进行操作,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。Jar包引入,pom.xml:<dependency>  <groupId>o...
    99+
    2023-05-31
    java hdfs
  • C#中怎么对Word进行操作
    C#中怎么对Word进行操作,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。导入COM库:Microsoft word 11.0 Object Library.引用里面就增加了:...
    99+
    2023-06-17
  • 怎么在Java中利用File对文件进行操作
    本篇文章为大家展示了怎么在Java中利用File对文件进行操作,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。1.1java.io.FileFile用于表示文件系统中的一个文件或目录通过File可以:...
    99+
    2023-05-31
    java file
  • 怎么在java项目中利用mongodb进行查询操作
    本篇文章为大家展示了怎么在java项目中利用mongodb进行查询操作,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。java 中mongodb的各种操作查询的实例详解一. 常用查询: 查询一条数据:...
    99+
    2023-05-31
    java mongodb
  • Java中怎么利用Streams对数据库进行查询操作
    Java中怎么利用Streams对数据库进行查询操作,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。示例数据库我们使用的示例数据库是Saki...
    99+
    2024-04-02
  • 利用Java怎么对redis进行增删查改操作
    利用Java怎么对redis进行增删查改操作?很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。首先,需要在windows下配置一个redis环境,然后需要导入:je...
    99+
    2023-05-31
    java redis
  • 怎么在Python中利用Selenium对Cookie进行操作
    本文章向大家介绍怎么在Python中利用Selenium对Cookie进行操作的基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。python是什么意思Python是一种跨平台的、具有解释性、编译性、互动性和面向对象...
    99+
    2023-06-06
  • C#中怎么利用FileStream对文件进行操作
    C#中怎么利用FileStream对文件进行操作,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。C# FileStream写文件的操作实例:///先导入命名空间:...
    99+
    2023-06-17
  • 怎么在python中利用loguru对日志进行操作
    本篇文章为大家展示了怎么在python中利用loguru对日志进行操作,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。python可以做什么Python是一种编程语言,内置了许多有效的工具,Pytho...
    99+
    2023-06-14
  • Android中怎么利用LitePal对数据库进行操作
    Android中怎么利用LitePal对数据库进行操作,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。首先在app/build.grade文件中编辑dependencies{.....
    99+
    2023-06-04
  • word模板怎么利用springMVC进行导出
    word模板怎么利用springMVC进行导出?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。controller 调用@RequestMapping(value = &qu...
    99+
    2023-05-31
    springmvc word
  • 使用java怎么对elasticsearch进行操作
    这期内容当中小编将会给大家带来有关使用java怎么对elasticsearch进行操作,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。Java操作es集群步骤1:配置集群对象信息;2:创建客户端;3:查看集...
    99+
    2023-05-30
  • ODBC中怎么利用CRecordset类对数据库进行操作
    ODBC中怎么利用CRecordset类对数据库进行操作,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。 1.MFC中的ODBC类...
    99+
    2024-04-02
  • 怎么在python中利用openpyxl和xlsxwriter对Excel进行操作
    本篇文章给大家分享的是有关怎么在python中利用openpyxl和xlsxwriter对Excel进行操作,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。简介Python中操作...
    99+
    2023-06-06
  • Java 7中怎么对文件进行操作
    这篇文章将为大家详细讲解有关Java 7中怎么对文件进行操作,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。创建和删除文件下面的代码片段向你展示的是用 Files.createFile(Pat...
    99+
    2023-06-17
  • Java项目中的word文档如何利用Freemarker进行导出
    本篇文章给大家分享的是有关Java项目中的word文档如何利用Freemarker进行导出,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。实现步骤用Microsoft Offic...
    99+
    2023-05-31
    freemarker word java
  • Android应用中SQLite数据库怎么利用listview控件进行操作
    今天就跟大家聊聊有关Android应用中SQLite数据库怎么利用listview控件进行操作,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。利用SQLiteOpenHelper类建立...
    99+
    2023-05-31
    listview sqlite lite
  • 怎么在java中利用default操作接口
    怎么在java中利用default操作接口?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。常用的java框架有哪些1.SpringMVC,Spring Web MVC是一种基...
    99+
    2023-06-14
  • java 中怎么利用org.w3c.dom操作XML文件
    java 中怎么利用org.w3c.dom操作XML文件,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。下面直接贴出样例代码:import javax.xml.pa...
    99+
    2023-06-20
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作