Java (480)
This article demonstrates how to add or delete rows and columns in a PowerPoint table using Spire.Presentation for Java.
Here is a screenshot of the sample PowerPoint file:

Add a row and a column
import com.spire.presentation.*;
public class AddRowAndColumn {
public static void main(String[] args) throws Exception {
//load the sample PowerPoint file
Presentation presentation = new Presentation();
presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\input.pptx");
//get the table in the document
ITable table = null;
for (Object shape : presentation.getSlides().get(0).getShapes()) {
if (shape instanceof ITable) {
table = (ITable) shape;
//add the last row to the end of the table as a new row
int rowCount = table.getTableRows().getCount();
TableRow row = table.getTableRows().get(rowCount - 1);
table.getTableRows().append(row);
//get the new row and set the text for each cell
rowCount = table.getTableRows().getCount();
row = table.getTableRows().get(rowCount - 1);
row.get(0).getTextFrame().setText("America");
row.get(1).getTextFrame().setText("Washington");
row.get(2).getTextFrame().setText("North America");
row.get(3).getTextFrame().setText("9372610");
//add the last column to the end of the table as a new column
int colCount = table.getColumnsList().getCount();
TableColumn column =table.getColumnsList().get(colCount-1);
table.getColumnsList().add(column);
//get the new column and set the text for each cell
colCount = table.getColumnsList().getCount();
column = table.getColumnsList().get(colCount-1);
column.get(0).getTextFrame().setText("Population");
column.get(1).getTextFrame().setText("32370000");
column.get(2).getTextFrame().setText("7350000");
column.get(3).getTextFrame().setText("15040000");
column.get(4).getTextFrame().setText("26500000");
column.get(5).getTextFrame().setText("329740000");
}
}
//save the document
presentation.saveToFile("output/AddRowAndColumn.pptx", FileFormat.PPTX_2013);
}
}

Delete a row and a column
import com.spire.presentation.FileFormat;
import com.spire.presentation.ITable;
import com.spire.presentation.Presentation;
public class DeleteRowAndColumn {
public static void main(String[] args) throws Exception {
//load the sample PowerPoint file
Presentation presentation = new Presentation();
presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\input.pptx");
//get the table in the document
ITable table = null;
for (Object shape : presentation.getSlides().get(0).getShapes()) {
if (shape instanceof ITable) {
table = (ITable) shape;
//delete the second column
table.getColumnsList().removeAt(1, false);
//delete the second row
table.getTableRows().removeAt(1, false);
}
}
//save the document
presentation.saveToFile("output/DeleteRowAndColumn.pptx", FileFormat.PPTX_2013);
}
}

Published in
Table
Tagged under
This article demonstrates how to modify hyperlinks in Word including modifying hyperlink address and display text using Spire.Doc for Java.
Below is the sample Word document we used for demonstration:

import com.spire.doc.*;
import com.spire.doc.documents.*;
import com.spire.doc.fields.Field;
import java.util.ArrayList;
import java.util.List;
public class ModifyHyperlink {
public static void main(String[] args) {
//Load Word document
Document doc = new Document();
doc.loadFromFile("Hyperlink.docx");
List hyperlinks = new ArrayList();
//Loop through the section in the document
for (Section section : (Iterable<Section>) doc.getSections()
) {
//Loop through the section in the document
for (Paragraph para : (Iterable<Paragraph>) section.getParagraphs()
) {
for (DocumentObject obj:(Iterable<DocumentObject>) para.getChildObjects()
) {
if (obj.getDocumentObjectType().equals(DocumentObjectType.Field)) {
Field field = (Field) obj;
if (field.getType().equals(FieldType.Field_Hyperlink)) {
hyperlinks.add(field);
}
}
}
}
}
hyperlinks.get(0).setCode("HYPERLINK \"http://www.google.com\"");
hyperlinks.get(0).setFieldText("www.google.com");
doc.saveToFile("EditHyperlink.docx", FileFormat.Docx_2013);
}
}
Output:

Published in
Hyperlink
Tagged under
We have already demonstrated how to use Spire.Doc to insert footnote to word document in Java applications. This article will show how to remove footnote from word document in Java.
Firstly, view the sample document with footnotes:

import com.spire.doc.*;
import com.spire.doc.documents.Paragraph;
import com.spire.doc.fields.*;
public class RemoveFootnote {
public static void main(String[] args) throws Exception {
//Load the Sample Word document.
Document document = new Document();
document.loadFromFile("Sample.docx");
Section section = document.getSections().get(0);
//Traverse paragraphs in the section and find the footnote
for (int j = 0; j < section.getParagraphs().getCount(); j++) {
Paragraph para = section.getParagraphs().get(j);
int index = -1;
for (int i = 0, cnt = para.getChildObjects().getCount(); i < cnt; i++) {
ParagraphBase pBase = (ParagraphBase) para.getChildObjects().get(i);
if (pBase instanceof Footnote) {
index = i;
break;
}
}
if (index > -1)
//remove the footnote
para.getChildObjects().removeAt(index);
}
document.saveToFile("Removefootnote.docx", FileFormat.Docx);
}
}
Effective screenshot after remove the footnote from word document:

Published in
FootNote
Tagged under