Search in sources :

Example 1 with BackupRecord

use of org.apache.poi.hssf.record.BackupRecord in project poi by apache.

the class InternalWorkbook method createBackup.

/**
     * creates the Backup record with backup set to 0. (loose the data, who cares)
     */
private static BackupRecord createBackup() {
    BackupRecord retval = new BackupRecord();
    // by default DONT save backups of files...just loose data
    retval.setBackup((short) 0);
    return retval;
}
Also used : BackupRecord(org.apache.poi.hssf.record.BackupRecord)

Example 2 with BackupRecord

use of org.apache.poi.hssf.record.BackupRecord in project poi by apache.

the class HSSFWorkbook method setBackupFlag.

/**
     * determine whether the Excel GUI will backup the workbook when saving.
     *
     * @param backupValue   true to indicate a backup will be performed.
     */
public void setBackupFlag(boolean backupValue) {
    BackupRecord backupRecord = workbook.getBackupRecord();
    backupRecord.setBackup(backupValue ? (short) 1 : (short) 0);
}
Also used : BackupRecord(org.apache.poi.hssf.record.BackupRecord)

Example 3 with BackupRecord

use of org.apache.poi.hssf.record.BackupRecord in project poi by apache.

the class TestWorkbook method testBackupRecord.

/**
     * Test the backup field gets set as expected.
     * @throws IOException 
     */
@Test
public void testBackupRecord() throws IOException {
    HSSFWorkbook wb = new HSSFWorkbook();
    wb.createSheet();
    InternalWorkbook workbook = wb.getWorkbook();
    BackupRecord record = workbook.getBackupRecord();
    assertEquals(0, record.getBackup());
    assertFalse(wb.getBackupFlag());
    wb.setBackupFlag(true);
    assertEquals(1, record.getBackup());
    assertTrue(wb.getBackupFlag());
    wb.setBackupFlag(false);
    assertEquals(0, record.getBackup());
    assertFalse(wb.getBackupFlag());
    wb.close();
}
Also used : BackupRecord(org.apache.poi.hssf.record.BackupRecord) InternalWorkbook(org.apache.poi.hssf.model.InternalWorkbook) Test(org.junit.Test)

Aggregations

BackupRecord (org.apache.poi.hssf.record.BackupRecord)3 InternalWorkbook (org.apache.poi.hssf.model.InternalWorkbook)1 Test (org.junit.Test)1