com.hfg.xml.msoffice2003.spreadsheetml.ExcelWorksheetOptions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com_hfg Show documentation
Show all versions of com_hfg Show documentation
com.hfg xml, html, svg, and bioinformatics utility library
package com.hfg.xml.msoffice2003.spreadsheetml;
import com.hfg.xml.XMLTag;
//------------------------------------------------------------------------------
/**
Excel worksheet options.
@author J. Alex Taylor, hairyfatguy.com
*/
//------------------------------------------------------------------------------
// com.hfg Library
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
// [email protected]
//------------------------------------------------------------------------------
public class ExcelWorksheetOptions extends XMLTag
{
//---------------------------------------------------------------------------
public ExcelWorksheetOptions()
{
super(SpreadsheetML.WORKSHEET_OPTIONS);
}
//###########################################################################
// PUBLIC METHODS
//###########################################################################
//---------------------------------------------------------------------------
public ExcelWorksheetOptions setSelected(boolean inValue)
{
removeSubtagsByName(SpreadsheetML.SELECTED);
if (inValue)
{
addSubtag(new XMLTag(SpreadsheetML.SELECTED));
}
return this;
}
//---------------------------------------------------------------------------
public ExcelWorksheetOptions freezePaneAboveRow(int inRowIndex)
{
clearFreezeSettings();
addSubtag(new XMLTag(SpreadsheetML.FREEZE_PANES));
addSubtag(new XMLTag(SpreadsheetML.FROZEN_NO_SPLIT));
addSubtag(new XMLTag(SpreadsheetML.SPLIT_HORIZONTAL).setContent((inRowIndex - 1) + ""));
addSubtag(new XMLTag(SpreadsheetML.TOP_ROW_BOTTOM_PANE).setContent((inRowIndex - 1) + ""));
addSubtag(new XMLTag(SpreadsheetML.ACTIVE_PANE).setContent(ExcelWorksheet.Pane.LOWER_LEFT.value()));
/*
3
2
6
1
*/
XMLTag panesTag = new XMLTag(SpreadsheetML.PANES);
addSubtag(panesTag);
XMLTag paneTag = new XMLTag(SpreadsheetML.PANE);
panesTag.addSubtag(paneTag);
paneTag.addSubtag(new XMLTag(SpreadsheetML.NUMBER).setContent(ExcelWorksheet.Pane.UPPER_LEFT.value()));
paneTag = new XMLTag(SpreadsheetML.PANE);
panesTag.addSubtag(paneTag);
paneTag.addSubtag(new XMLTag(SpreadsheetML.NUMBER).setContent(ExcelWorksheet.Pane.LOWER_LEFT.value()));
return this;
}
//---------------------------------------------------------------------------
public ExcelWorksheetOptions freezePaneLeftOfColumn(int inColumnIndex)
{
clearFreezeSettings();
addSubtag(new XMLTag(SpreadsheetML.FREEZE_PANES));
addSubtag(new XMLTag(SpreadsheetML.FROZEN_NO_SPLIT));
addSubtag(new XMLTag(SpreadsheetML.SPLIT_VERTICAL).setContent((inColumnIndex - 1) + ""));
addSubtag(new XMLTag(SpreadsheetML.LEFT_COLUMN_RIGHT_PANE).setContent((inColumnIndex - 1) + ""));
addSubtag(new XMLTag(SpreadsheetML.ACTIVE_PANE).setContent(ExcelWorksheet.Pane.UPPER_RIGHT.value()));
XMLTag panesTag = new XMLTag(SpreadsheetML.PANES);
addSubtag(panesTag);
XMLTag paneTag = new XMLTag(SpreadsheetML.PANE);
panesTag.addSubtag(paneTag);
paneTag.addSubtag(new XMLTag(SpreadsheetML.NUMBER).setContent(ExcelWorksheet.Pane.UPPER_LEFT.value()));
paneTag = new XMLTag(SpreadsheetML.PANE);
panesTag.addSubtag(paneTag);
paneTag.addSubtag(new XMLTag(SpreadsheetML.NUMBER).setContent(ExcelWorksheet.Pane.UPPER_RIGHT.value()));
return this;
}
//---------------------------------------------------------------------------
/**
Freezes the region above and to the left of the selected cell.
*/
public ExcelWorksheetOptions freezePane(int inRowIndex, int inColumnIndex)
{
if (inRowIndex <= 1)
{
if (inColumnIndex > 1)
{
freezePaneLeftOfColumn(inColumnIndex);
}
}
else if (inColumnIndex <= 1)
{
freezePaneAboveRow(inRowIndex);
}
else
{
clearFreezeSettings();
addSubtag(new XMLTag(SpreadsheetML.FREEZE_PANES));
addSubtag(new XMLTag(SpreadsheetML.FROZEN_NO_SPLIT));
addSubtag(new XMLTag(SpreadsheetML.SPLIT_VERTICAL).setContent((inColumnIndex - 1) + ""));
addSubtag(new XMLTag(SpreadsheetML.SPLIT_HORIZONTAL).setContent((inRowIndex - 1) + ""));
addSubtag(new XMLTag(SpreadsheetML.LEFT_COLUMN_RIGHT_PANE).setContent((inColumnIndex - 1) + ""));
addSubtag(new XMLTag(SpreadsheetML.TOP_ROW_BOTTOM_PANE).setContent((inRowIndex - 1) + ""));
addSubtag(new XMLTag(SpreadsheetML.ACTIVE_PANE).setContent(ExcelWorksheet.Pane.LOWER_RIGHT.value()));
XMLTag panesTag = new XMLTag(SpreadsheetML.PANES);
addSubtag(panesTag);
XMLTag paneTag = new XMLTag(SpreadsheetML.PANE);
panesTag.addSubtag(paneTag);
paneTag.addSubtag(new XMLTag(SpreadsheetML.NUMBER).setContent(ExcelWorksheet.Pane.UPPER_LEFT.value()));
paneTag = new XMLTag(SpreadsheetML.PANE);
panesTag.addSubtag(paneTag);
paneTag.addSubtag(new XMLTag(SpreadsheetML.NUMBER).setContent(ExcelWorksheet.Pane.LOWER_LEFT.value()));
paneTag = new XMLTag(SpreadsheetML.PANE);
panesTag.addSubtag(paneTag);
paneTag.addSubtag(new XMLTag(SpreadsheetML.NUMBER).setContent(ExcelWorksheet.Pane.UPPER_RIGHT.value()));
paneTag = new XMLTag(SpreadsheetML.PANE);
panesTag.addSubtag(paneTag);
paneTag.addSubtag(new XMLTag(SpreadsheetML.NUMBER).setContent(ExcelWorksheet.Pane.LOWER_RIGHT.value()));
}
return this;
}
//---------------------------------------------------------------------------
private void clearFreezeSettings()
{
removeSubtagsByName(SpreadsheetML.FREEZE_PANES);
removeSubtagsByName(SpreadsheetML.FROZEN_NO_SPLIT);
removeSubtagsByName(SpreadsheetML.SPLIT_HORIZONTAL);
removeSubtagsByName(SpreadsheetML.SPLIT_VERTICAL);
removeSubtagsByName(SpreadsheetML.TOP_ROW_BOTTOM_PANE);
removeSubtagsByName(SpreadsheetML.LEFT_COLUMN_RIGHT_PANE);
removeSubtagsByName(SpreadsheetML.ACTIVE_PANE);
removeSubtagsByName(SpreadsheetML.PANES);
}
}