B4J Question [XLUtils] Word -- Number of Columns and Widow/Orphan Control?

dank

Member
Licensed User
Longtime User
Is it possible to change the number of columns in a Word document using XLUtils? Also, what about Widow/Orphan control? With both, it's a perfect solution for me.

Thanks.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User


You can add columns with this code:
B4X:
Private Sub CreateColumns (doc As WordDocument, Count As Int)
    Me.As(JavaObject).RunMethod("createColumns", Array(doc.XWPFDocument, Count))
End Sub

#if Java
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import org.apache.poi.xwpf.usermodel.*;
import java.math.*;
public void createColumns(XWPFDocument document, int count) {
    CTBody ctBody = document.getDocument().getBody();
    CTSectPr ctSectPr = ctBody.getSectPr() == null ? ctBody.addNewSectPr() : ctBody.getSectPr();
    for (int i = 0;i < count;i++) {
        CTColumns col = ctSectPr.addNewCols();
        col.setNum(BigInteger.valueOf(i + 1));
    }
}
#End If

Example:
B4X:
Dim doc As WordDocument = wd.CreateDocument
CreateColumns(doc, 3)

It depends on the "full" package: https://www.b4x.com/android/forum/t...d-write-ms-excel-workbooks.129969/post-832993
 
Upvote 0

dank

Member
Licensed User
Longtime User
Fantastic! Thanks!

Is there any way to check to see if part of a paragraph, section, or sentence will spill over to a new page? I need to make sure paragraphs, etc. are kept together on the same page.

Thanks again.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Is there any way to check to see if part of a paragraph, section, or sentence will spill over to a new page? I need to make sure paragraphs, etc. are kept together on the same page.
No. The actual layout only happens when you open the document in MS Word.
You can play with page breaks to start on the next page. For further discussion please start a new thread.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…