mirror of https://github.com/apache/poi.git
bug 59645: add Page Setup Print row and column headings support for Common SS
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1749191 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
41517168f9
commit
9a769fcb0b
|
@ -103,6 +103,7 @@ public final class InternalSheet {
|
||||||
|
|
||||||
private List<RecordBase> _records;
|
private List<RecordBase> _records;
|
||||||
protected PrintGridlinesRecord printGridlines = null;
|
protected PrintGridlinesRecord printGridlines = null;
|
||||||
|
protected PrintHeadersRecord printHeaders = null;
|
||||||
protected GridsetRecord gridset = null;
|
protected GridsetRecord gridset = null;
|
||||||
private GutsRecord _gutsRecord;
|
private GutsRecord _gutsRecord;
|
||||||
protected DefaultColWidthRecord defaultcolwidth = new DefaultColWidthRecord();
|
protected DefaultColWidthRecord defaultcolwidth = new DefaultColWidthRecord();
|
||||||
|
@ -313,6 +314,10 @@ public final class InternalSheet {
|
||||||
{
|
{
|
||||||
printGridlines = (PrintGridlinesRecord) rec;
|
printGridlines = (PrintGridlinesRecord) rec;
|
||||||
}
|
}
|
||||||
|
else if ( recSid == PrintHeadersRecord.sid )
|
||||||
|
{
|
||||||
|
printHeaders = (PrintHeadersRecord) rec;
|
||||||
|
}
|
||||||
else if ( recSid == GridsetRecord.sid )
|
else if ( recSid == GridsetRecord.sid )
|
||||||
{
|
{
|
||||||
gridset = (GridsetRecord) rec;
|
gridset = (GridsetRecord) rec;
|
||||||
|
@ -455,7 +460,8 @@ public final class InternalSheet {
|
||||||
records.add(createIteration() );
|
records.add(createIteration() );
|
||||||
records.add(createDelta() );
|
records.add(createDelta() );
|
||||||
records.add(createSaveRecalc() );
|
records.add(createSaveRecalc() );
|
||||||
records.add(createPrintHeaders() );
|
printHeaders = createPrintHeaders();
|
||||||
|
records.add(printHeaders);
|
||||||
printGridlines = createPrintGridlines();
|
printGridlines = createPrintGridlines();
|
||||||
records.add( printGridlines );
|
records.add( printGridlines );
|
||||||
gridset = createGridset();
|
gridset = createGridset();
|
||||||
|
@ -1345,6 +1351,24 @@ public final class InternalSheet {
|
||||||
printGridlines = newPrintGridlines;
|
printGridlines = newPrintGridlines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the PrintHeadersRecord.
|
||||||
|
* @return PrintHeadersRecord for the sheet.
|
||||||
|
*/
|
||||||
|
public PrintHeadersRecord getPrintHeaders()
|
||||||
|
{
|
||||||
|
return printHeaders;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the PrintHeadersRecord.
|
||||||
|
* @param newPrintHeaders The new PrintHeadersRecord for the sheet.
|
||||||
|
*/
|
||||||
|
public void setPrintHeaders(PrintHeadersRecord newPrintHeaders)
|
||||||
|
{
|
||||||
|
printHeaders = newPrintHeaders;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether the sheet is selected
|
* Sets whether the sheet is selected
|
||||||
* @param sel True to select the sheet, false otherwise.
|
* @param sel True to select the sheet, false otherwise.
|
||||||
|
@ -1511,6 +1535,22 @@ public final class InternalSheet {
|
||||||
return windowTwo.getDisplayRowColHeadings();
|
return windowTwo.getDisplayRowColHeadings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether the RowColHeadings are shown in a viewer.
|
||||||
|
* @param show whether to show RowColHeadings or not
|
||||||
|
*/
|
||||||
|
public void setPrintRowColHeadings(boolean show) {
|
||||||
|
windowTwo.setDisplayRowColHeadings(show);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if RowColHeadings are displayed.
|
||||||
|
* @return whether RowColHeadings are displayed
|
||||||
|
*/
|
||||||
|
public boolean isPrintRowColHeadings() {
|
||||||
|
return windowTwo.getDisplayRowColHeadings();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return whether an uncalced record must be inserted or not at generation
|
* @return whether an uncalced record must be inserted or not at generation
|
||||||
|
|
|
@ -1199,12 +1199,33 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
|
||||||
/**
|
/**
|
||||||
* Turns on or off the printing of gridlines.
|
* Turns on or off the printing of gridlines.
|
||||||
*
|
*
|
||||||
* @param newPrintGridlines boolean to turn on or off the printing of
|
* @param show boolean to turn on or off the printing of
|
||||||
* gridlines
|
* gridlines
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setPrintGridlines(boolean newPrintGridlines) {
|
public void setPrintGridlines(boolean show) {
|
||||||
getSheet().getPrintGridlines().setPrintGridlines(newPrintGridlines);
|
getSheet().getPrintGridlines().setPrintGridlines(show);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether row and column headings are printed.
|
||||||
|
*
|
||||||
|
* @return row and column headings are printed
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean isPrintRowAndColumnHeadings() {
|
||||||
|
return getSheet().getPrintHeaders().getPrintHeaders();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns on or off the printing of row and column headings.
|
||||||
|
*
|
||||||
|
* @param show boolean to turn on or off the printing of
|
||||||
|
* row and column headings
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setPrintRowAndColumnHeadings(boolean show) {
|
||||||
|
getSheet().getPrintHeaders().setPrintHeaders(show);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -511,22 +511,36 @@ public interface Sheet extends Iterable<Row> {
|
||||||
* Gets the flag indicating whether this sheet displays the lines
|
* Gets the flag indicating whether this sheet displays the lines
|
||||||
* between rows and columns to make editing and reading easier.
|
* between rows and columns to make editing and reading easier.
|
||||||
*
|
*
|
||||||
* @return <code>true</code> if this sheet displays gridlines.
|
* @return <code>true</code> if this sheet prints gridlines.
|
||||||
* @see #isPrintGridlines() to check if printing of gridlines is turned on or off
|
* @see #isDisplayGridlines() to check if gridlines are displayed on screen
|
||||||
*/
|
*/
|
||||||
boolean isPrintGridlines();
|
boolean isPrintGridlines();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the flag indicating whether this sheet should display the lines
|
* Sets the flag indicating whether this sheet should print the lines
|
||||||
* between rows and columns to make editing and reading easier.
|
* between rows and columns to make editing and reading easier.
|
||||||
* To turn printing of gridlines use {@link #setPrintGridlines(boolean)}
|
|
||||||
*
|
*
|
||||||
*
|
* @param show <code>true</code> if this sheet should print gridlines.
|
||||||
* @param show <code>true</code> if this sheet should display gridlines.
|
* @see #setDisplayGridlines(boolean) to display gridlines on screen
|
||||||
* @see #setPrintGridlines(boolean)
|
|
||||||
*/
|
*/
|
||||||
void setPrintGridlines(boolean show);
|
void setPrintGridlines(boolean show);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the flag indicating whether this sheet prints the
|
||||||
|
* row and column headings when printing.
|
||||||
|
*
|
||||||
|
* @return <code>true</code> if this sheet prints row and column headings.
|
||||||
|
*/
|
||||||
|
boolean isPrintRowAndColumnHeadings();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the flag indicating whether this sheet should print
|
||||||
|
* row and columns headings when printing.
|
||||||
|
*
|
||||||
|
* @param show <code>true</code> if this sheet should print row and column headings.
|
||||||
|
*/
|
||||||
|
void setPrintRowAndColumnHeadings(boolean show);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the print setup object.
|
* Gets the print setup object.
|
||||||
*
|
*
|
||||||
|
|
|
@ -704,11 +704,9 @@ public class SXSSFSheet implements Sheet, Cloneable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the flag indicating whether this sheet displays the lines
|
* Returns whether gridlines are printed.
|
||||||
* between rows and columns to make editing and reading easier.
|
|
||||||
*
|
*
|
||||||
* @return <code>true</code> if this sheet displays gridlines.
|
* @return whether gridlines are printed
|
||||||
* @see #isPrintGridlines() to check if printing of gridlines is turned on or off
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isPrintGridlines()
|
public boolean isPrintGridlines()
|
||||||
|
@ -717,13 +715,9 @@ public class SXSSFSheet implements Sheet, Cloneable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the flag indicating whether this sheet should display the lines
|
* Turns on or off the printing of gridlines.
|
||||||
* between rows and columns to make editing and reading easier.
|
|
||||||
* To turn printing of gridlines use {@link #setPrintGridlines(boolean)}
|
|
||||||
*
|
*
|
||||||
*
|
* @param show boolean to turn on or off the printing of gridlines
|
||||||
* @param show <code>true</code> if this sheet should display gridlines.
|
|
||||||
* @see #setPrintGridlines(boolean)
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setPrintGridlines(boolean show)
|
public void setPrintGridlines(boolean show)
|
||||||
|
@ -731,6 +725,28 @@ public class SXSSFSheet implements Sheet, Cloneable
|
||||||
_sh.setPrintGridlines(show);
|
_sh.setPrintGridlines(show);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether row and column headings are printed.
|
||||||
|
*
|
||||||
|
* @return whether row and column headings are printed
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean isPrintRowAndColumnHeadings()
|
||||||
|
{
|
||||||
|
return _sh.isPrintRowAndColumnHeadings();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns on or off the printing of row and column headings.
|
||||||
|
*
|
||||||
|
* @param show boolean to turn on or off the printing of row and column headings
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setPrintRowAndColumnHeadings(boolean show)
|
||||||
|
{
|
||||||
|
_sh.setPrintRowAndColumnHeadings(show);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the print setup object.
|
* Gets the print setup object.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1758,6 +1758,29 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
||||||
opts.setGridLines(value);
|
opts.setGridLines(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether row and column headings are printed.
|
||||||
|
*
|
||||||
|
* @return whether row and column headings are printed
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean isPrintRowAndColumnHeadings() {
|
||||||
|
CTPrintOptions opts = worksheet.getPrintOptions();
|
||||||
|
return opts != null && opts.getHeadings();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns on or off the printing of row and column headings.
|
||||||
|
*
|
||||||
|
* @param value boolean to turn on or off the printing of row and column headings
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setPrintRowAndColumnHeadings(boolean value) {
|
||||||
|
CTPrintOptions opts = worksheet.isSetPrintOptions() ?
|
||||||
|
worksheet.getPrintOptions() : worksheet.addNewPrintOptions();
|
||||||
|
opts.setHeadings(value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests if there is a page break at the indicated row
|
* Tests if there is a page break at the indicated row
|
||||||
*
|
*
|
||||||
|
|
|
@ -682,7 +682,7 @@ public abstract class BaseTestSheet {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test basic display properties
|
* Test basic display and print properties
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void sheetProperties() throws IOException {
|
public void sheetProperties() throws IOException {
|
||||||
|
@ -705,6 +705,10 @@ public abstract class BaseTestSheet {
|
||||||
sheet.setPrintGridlines(true);
|
sheet.setPrintGridlines(true);
|
||||||
assertTrue(sheet.isPrintGridlines());
|
assertTrue(sheet.isPrintGridlines());
|
||||||
|
|
||||||
|
assertFalse(sheet.isPrintRowAndColumnHeadings());
|
||||||
|
sheet.setPrintRowAndColumnHeadings(true);
|
||||||
|
assertTrue(sheet.isPrintRowAndColumnHeadings());
|
||||||
|
|
||||||
assertFalse(sheet.isDisplayFormulas());
|
assertFalse(sheet.isDisplayFormulas());
|
||||||
sheet.setDisplayFormulas(true);
|
sheet.setDisplayFormulas(true);
|
||||||
assertTrue(sheet.isDisplayFormulas());
|
assertTrue(sheet.isDisplayFormulas());
|
||||||
|
|
Loading…
Reference in New Issue