Changed CRLF to LF in remaining trunk/src files

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@780878 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2009-06-01 23:21:13 +00:00
parent f73c479d1b
commit fef0dc1ae5
9 changed files with 2298 additions and 2294 deletions

View File

@ -1,89 +1,89 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership. this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0 The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.hssf.usermodel.examples; package org.apache.poi.hssf.usermodel.examples;
import org.apache.poi.hssf.usermodel.*; import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.hssf.util.HSSFColor;
import java.io.IOException; import java.io.IOException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
/** /**
* Demonstrates how to create hyperlinks. * Demonstrates how to create hyperlinks.
* *
* @author Yegor Kozlov (yegor at apach.org) * @author Yegor Kozlov (yegor at apach.org)
*/ */
public class Hyperlinks { public class Hyperlinks {
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
//cell style for hyperlinks //cell style for hyperlinks
//by default hyperlinks are blue and underlined //by default hyperlinks are blue and underlined
HSSFCellStyle hlink_style = wb.createCellStyle(); HSSFCellStyle hlink_style = wb.createCellStyle();
HSSFFont hlink_font = wb.createFont(); HSSFFont hlink_font = wb.createFont();
hlink_font.setUnderline(HSSFFont.U_SINGLE); hlink_font.setUnderline(HSSFFont.U_SINGLE);
hlink_font.setColor(HSSFColor.BLUE.index); hlink_font.setColor(HSSFColor.BLUE.index);
hlink_style.setFont(hlink_font); hlink_style.setFont(hlink_font);
HSSFCell cell; HSSFCell cell;
HSSFSheet sheet = wb.createSheet("Hyperlinks"); HSSFSheet sheet = wb.createSheet("Hyperlinks");
//URL //URL
cell = sheet.createRow(0).createCell(0); cell = sheet.createRow(0).createCell(0);
cell.setCellValue("URL Link"); cell.setCellValue("URL Link");
HSSFHyperlink link = new HSSFHyperlink(HSSFHyperlink.LINK_URL); HSSFHyperlink link = new HSSFHyperlink(HSSFHyperlink.LINK_URL);
link.setAddress("http://poi.apache.org/"); link.setAddress("http://poi.apache.org/");
cell.setHyperlink(link); cell.setHyperlink(link);
cell.setCellStyle(hlink_style); cell.setCellStyle(hlink_style);
//link to a file in the current directory //link to a file in the current directory
cell = sheet.createRow(1).createCell(0); cell = sheet.createRow(1).createCell(0);
cell.setCellValue("File Link"); cell.setCellValue("File Link");
link = new HSSFHyperlink(HSSFHyperlink.LINK_FILE); link = new HSSFHyperlink(HSSFHyperlink.LINK_FILE);
link.setAddress("link1.xls"); link.setAddress("link1.xls");
cell.setHyperlink(link); cell.setHyperlink(link);
cell.setCellStyle(hlink_style); cell.setCellStyle(hlink_style);
//e-mail link //e-mail link
cell = sheet.createRow(2).createCell(0); cell = sheet.createRow(2).createCell(0);
cell.setCellValue("Email Link"); cell.setCellValue("Email Link");
link = new HSSFHyperlink(HSSFHyperlink.LINK_EMAIL); link = new HSSFHyperlink(HSSFHyperlink.LINK_EMAIL);
//note, if subject contains white spaces, make sure they are url-encoded //note, if subject contains white spaces, make sure they are url-encoded
link.setAddress("mailto:poi@apache.org?subject=Hyperlinks"); link.setAddress("mailto:poi@apache.org?subject=Hyperlinks");
cell.setHyperlink(link); cell.setHyperlink(link);
cell.setCellStyle(hlink_style); cell.setCellStyle(hlink_style);
//link to a place in this workbook //link to a place in this workbook
//create a target sheet and cell //create a target sheet and cell
HSSFSheet sheet2 = wb.createSheet("Target Sheet"); HSSFSheet sheet2 = wb.createSheet("Target Sheet");
sheet2.createRow(0).createCell(0).setCellValue("Target Cell"); sheet2.createRow(0).createCell(0).setCellValue("Target Cell");
cell = sheet.createRow(3).createCell(0); cell = sheet.createRow(3).createCell(0);
cell.setCellValue("Worksheet Link"); cell.setCellValue("Worksheet Link");
link = new HSSFHyperlink(HSSFHyperlink.LINK_DOCUMENT); link = new HSSFHyperlink(HSSFHyperlink.LINK_DOCUMENT);
link.setAddress("'Target Sheet'!A1"); link.setAddress("'Target Sheet'!A1");
cell.setHyperlink(link); cell.setHyperlink(link);
cell.setCellStyle(hlink_style); cell.setCellStyle(hlink_style);
FileOutputStream out = new FileOutputStream("hssf-links.xls"); FileOutputStream out = new FileOutputStream("hssf-links.xls");
wb.write(out); wb.write(out);
out.close(); out.close();
} }
} }

View File

@ -1,324 +1,325 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership. this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0 The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.ss.examples;
package org.apache.poi.ss.examples;
import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import java.util.Map;
import java.util.HashMap; import java.util.Map;
import java.util.Calendar; import java.util.HashMap;
import java.io.FileOutputStream; import java.util.Calendar;
import java.text.SimpleDateFormat; import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
/**
* A business plan demo /**
* Usage: * A business plan demo
* BusinessPlan -xls|xlsx * Usage:
* * BusinessPlan -xls|xlsx
* @author Yegor Kozlov *
*/ * @author Yegor Kozlov
public class BusinessPlan { */
public class BusinessPlan {
private static SimpleDateFormat fmt = new SimpleDateFormat("dd-MMM");
private static SimpleDateFormat fmt = new SimpleDateFormat("dd-MMM");
private static final String[] titles = {
"ID", "Project Name", "Owner", "Days", "Start", "End"}; private static final String[] titles = {
"ID", "Project Name", "Owner", "Days", "Start", "End"};
//sample data to fill the sheet.
private static final String[][] data = { //sample data to fill the sheet.
{"1.0", "Marketing Research Tactical Plan", "J. Dow", "70", "9-Jul", null, private static final String[][] data = {
"x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x"}, {"1.0", "Marketing Research Tactical Plan", "J. Dow", "70", "9-Jul", null,
null, "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x"},
{"1.1", "Scope Definition Phase", "J. Dow", "10", "9-Jul", null, null,
"x", "x", null, null, null, null, null, null, null, null, null}, {"1.1", "Scope Definition Phase", "J. Dow", "10", "9-Jul", null,
{"1.1.1", "Define research objectives", "J. Dow", "3", "9-Jul", null, "x", "x", null, null, null, null, null, null, null, null, null},
"x", null, null, null, null, null, null, null, null, null, null}, {"1.1.1", "Define research objectives", "J. Dow", "3", "9-Jul", null,
{"1.1.2", "Define research requirements", "S. Jones", "7", "10-Jul", null, "x", null, null, null, null, null, null, null, null, null, null},
"x", "x", null, null, null, null, null, null, null, null, null}, {"1.1.2", "Define research requirements", "S. Jones", "7", "10-Jul", null,
{"1.1.3", "Determine in-house resource or hire vendor", "J. Dow", "2", "15-Jul", null, "x", "x", null, null, null, null, null, null, null, null, null},
"x", "x", null, null, null, null, null, null, null, null, null}, {"1.1.3", "Determine in-house resource or hire vendor", "J. Dow", "2", "15-Jul", null,
null, "x", "x", null, null, null, null, null, null, null, null, null},
{"1.2", "Vendor Selection Phase", "J. Dow", "19", "19-Jul", null, null,
null, "x", "x", "x", "x", null, null, null, null, null, null}, {"1.2", "Vendor Selection Phase", "J. Dow", "19", "19-Jul", null,
{"1.2.1", "Define vendor selection criteria", "J. Dow", "3", "19-Jul", null, null, "x", "x", "x", "x", null, null, null, null, null, null},
null, "x", null, null, null, null, null, null, null, null, null}, {"1.2.1", "Define vendor selection criteria", "J. Dow", "3", "19-Jul", null,
{"1.2.2", "Develop vendor selection questionnaire", "S. Jones, T. Wates", "2", "22-Jul", null, null, "x", null, null, null, null, null, null, null, null, null},
null, "x", "x", null, null, null, null, null, null, null, null}, {"1.2.2", "Develop vendor selection questionnaire", "S. Jones, T. Wates", "2", "22-Jul", null,
{"1.2.3", "Develop Statement of Work", "S. Jones", "4", "26-Jul", null, null, "x", "x", null, null, null, null, null, null, null, null},
null, null, "x", "x", null, null, null, null, null, null, null}, {"1.2.3", "Develop Statement of Work", "S. Jones", "4", "26-Jul", null,
{"1.2.4", "Evaluate proposal", "J. Dow, S. Jones", "4", "2-Aug", null, null, null, "x", "x", null, null, null, null, null, null, null},
null, null, null, "x", "x", null, null, null, null, null, null}, {"1.2.4", "Evaluate proposal", "J. Dow, S. Jones", "4", "2-Aug", null,
{"1.2.5", "Select vendor", "J. Dow", "1", "6-Aug", null, null, null, null, "x", "x", null, null, null, null, null, null},
null, null, null, null, "x", null, null, null, null, null, null}, {"1.2.5", "Select vendor", "J. Dow", "1", "6-Aug", null,
null, null, null, null, null, "x", null, null, null, null, null, null},
{"1.3", "Research Phase", "G. Lee", "47", "9-Aug", null, null,
null, null, null, null, "x", "x", "x", "x", "x", "x", "x"}, {"1.3", "Research Phase", "G. Lee", "47", "9-Aug", null,
{"1.3.1", "Develop market research information needs questionnaire", "G. Lee", "2", "9-Aug", null, null, null, null, null, "x", "x", "x", "x", "x", "x", "x"},
null, null, null, null, "x", null, null, null, null, null, null}, {"1.3.1", "Develop market research information needs questionnaire", "G. Lee", "2", "9-Aug", null,
{"1.3.2", "Interview marketing group for market research needs", "G. Lee", "2", "11-Aug", null, null, null, null, null, "x", null, null, null, null, null, null},
null, null, null, null, "x", "x", null, null, null, null, null}, {"1.3.2", "Interview marketing group for market research needs", "G. Lee", "2", "11-Aug", null,
{"1.3.3", "Document information needs", "G. Lee, S. Jones", "1", "13-Aug", null, null, null, null, null, "x", "x", null, null, null, null, null},
null, null, null, null, null, "x", null, null, null, null, null}, {"1.3.3", "Document information needs", "G. Lee, S. Jones", "1", "13-Aug", null,
}; null, null, null, null, null, "x", null, null, null, null, null},
};
public static void main(String[] args) throws Exception {
Workbook wb; public static void main(String[] args) throws Exception {
Workbook wb;
if(args.length > 0 && args[0].equals("-xls")) wb = new HSSFWorkbook();
else wb = new XSSFWorkbook(); if(args.length > 0 && args[0].equals("-xls")) wb = new HSSFWorkbook();
else wb = new XSSFWorkbook();
Map<String, CellStyle> styles = createStyles(wb);
Map<String, CellStyle> styles = createStyles(wb);
Sheet sheet = wb.createSheet("Business Plan");
Sheet sheet = wb.createSheet("Business Plan");
//turn off gridlines
sheet.setDisplayGridlines(false); //turn off gridlines
sheet.setPrintGridlines(false); sheet.setDisplayGridlines(false);
sheet.setFitToPage(true); sheet.setPrintGridlines(false);
sheet.setHorizontallyCenter(true); sheet.setFitToPage(true);
PrintSetup printSetup = sheet.getPrintSetup(); sheet.setHorizontallyCenter(true);
printSetup.setLandscape(true); PrintSetup printSetup = sheet.getPrintSetup();
printSetup.setLandscape(true);
//the following three statements are required only for HSSF
sheet.setAutobreaks(true); //the following three statements are required only for HSSF
printSetup.setFitHeight((short)1); sheet.setAutobreaks(true);
printSetup.setFitWidth((short)1); printSetup.setFitHeight((short)1);
printSetup.setFitWidth((short)1);
//the header row: centered text in 48pt font
Row headerRow = sheet.createRow(0); //the header row: centered text in 48pt font
headerRow.setHeightInPoints(12.75f); Row headerRow = sheet.createRow(0);
for (int i = 0; i < titles.length; i++) { headerRow.setHeightInPoints(12.75f);
Cell cell = headerRow.createCell(i); for (int i = 0; i < titles.length; i++) {
cell.setCellValue(titles[i]); Cell cell = headerRow.createCell(i);
cell.setCellStyle(styles.get("header")); cell.setCellValue(titles[i]);
} cell.setCellStyle(styles.get("header"));
//columns for 11 weeks starting from 9-Jul }
Calendar calendar = Calendar.getInstance(); //columns for 11 weeks starting from 9-Jul
int year = calendar.get(Calendar.YEAR); Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
calendar.setTime(fmt.parse("9-Jul"));
calendar.set(Calendar.YEAR, year); calendar.setTime(fmt.parse("9-Jul"));
for (int i = 0; i < 11; i++) { calendar.set(Calendar.YEAR, year);
Cell cell = headerRow.createCell(titles.length + i); for (int i = 0; i < 11; i++) {
cell.setCellValue(calendar); Cell cell = headerRow.createCell(titles.length + i);
cell.setCellStyle(styles.get("header_date")); cell.setCellValue(calendar);
calendar.roll(Calendar.WEEK_OF_YEAR, true); cell.setCellStyle(styles.get("header_date"));
} calendar.roll(Calendar.WEEK_OF_YEAR, true);
//freeze the first row }
sheet.createFreezePane(0, 1); //freeze the first row
sheet.createFreezePane(0, 1);
Row row;
Cell cell; Row row;
int rownum = 1; Cell cell;
for (int i = 0; i < data.length; i++, rownum++) { int rownum = 1;
row = sheet.createRow(rownum); for (int i = 0; i < data.length; i++, rownum++) {
if(data[i] == null) continue; row = sheet.createRow(rownum);
if(data[i] == null) continue;
for (int j = 0; j < data[i].length; j++) {
cell = row.createCell(j); for (int j = 0; j < data[i].length; j++) {
String styleName; cell = row.createCell(j);
boolean isHeader = i == 0 || data[i-1] == null; String styleName;
switch(j){ boolean isHeader = i == 0 || data[i-1] == null;
case 0: switch(j){
if(isHeader) { case 0:
styleName = "cell_b"; if(isHeader) {
cell.setCellValue(Double.parseDouble(data[i][j])); styleName = "cell_b";
} else { cell.setCellValue(Double.parseDouble(data[i][j]));
styleName = "cell_normal"; } else {
cell.setCellValue(data[i][j]); styleName = "cell_normal";
} cell.setCellValue(data[i][j]);
break; }
case 1: break;
if(isHeader) { case 1:
styleName = i == 0 ? "cell_h" : "cell_bb"; if(isHeader) {
} else { styleName = i == 0 ? "cell_h" : "cell_bb";
styleName = "cell_indented"; } else {
} styleName = "cell_indented";
cell.setCellValue(data[i][j]); }
break; cell.setCellValue(data[i][j]);
case 2: break;
styleName = isHeader ? "cell_b" : "cell_normal"; case 2:
cell.setCellValue(data[i][j]); styleName = isHeader ? "cell_b" : "cell_normal";
break; cell.setCellValue(data[i][j]);
case 3: break;
styleName = isHeader ? "cell_b_centered" : "cell_normal_centered"; case 3:
cell.setCellValue(Integer.parseInt(data[i][j])); styleName = isHeader ? "cell_b_centered" : "cell_normal_centered";
break; cell.setCellValue(Integer.parseInt(data[i][j]));
case 4: { break;
calendar.setTime(fmt.parse(data[i][j])); case 4: {
calendar.set(Calendar.YEAR, year); calendar.setTime(fmt.parse(data[i][j]));
cell.setCellValue(calendar); calendar.set(Calendar.YEAR, year);
styleName = isHeader ? "cell_b_date" : "cell_normal_date"; cell.setCellValue(calendar);
break; styleName = isHeader ? "cell_b_date" : "cell_normal_date";
} break;
case 5: { }
int r = rownum + 1; case 5: {
String fmla = "IF(AND(D"+r+",E"+r+"),E"+r+"+D"+r+",\"\")"; int r = rownum + 1;
cell.setCellFormula(fmla); String fmla = "IF(AND(D"+r+",E"+r+"),E"+r+"+D"+r+",\"\")";
styleName = isHeader ? "cell_bg" : "cell_g"; cell.setCellFormula(fmla);
break; styleName = isHeader ? "cell_bg" : "cell_g";
} break;
default: }
styleName = data[i][j] != null ? "cell_blue" : "cell_normal"; default:
} styleName = data[i][j] != null ? "cell_blue" : "cell_normal";
}
cell.setCellStyle(styles.get(styleName));
} cell.setCellStyle(styles.get(styleName));
} }
}
//group rows for each phase, row numbers are 0-based
sheet.groupRow(4, 6); //group rows for each phase, row numbers are 0-based
sheet.groupRow(9, 13); sheet.groupRow(4, 6);
sheet.groupRow(16, 18); sheet.groupRow(9, 13);
sheet.groupRow(16, 18);
//set column widths, the width is measured in units of 1/256th of a character width
sheet.setColumnWidth(0, 256*6); //set column widths, the width is measured in units of 1/256th of a character width
sheet.setColumnWidth(1, 256*33); sheet.setColumnWidth(0, 256*6);
sheet.setColumnWidth(2, 256*20); sheet.setColumnWidth(1, 256*33);
sheet.setZoom(3, 4); sheet.setColumnWidth(2, 256*20);
sheet.setZoom(3, 4);
// Write the output to a file
String file = "businessplan.xls"; // Write the output to a file
if(wb instanceof XSSFWorkbook) file += "x"; String file = "businessplan.xls";
FileOutputStream out = new FileOutputStream(file); if(wb instanceof XSSFWorkbook) file += "x";
wb.write(out); FileOutputStream out = new FileOutputStream(file);
out.close(); wb.write(out);
} out.close();
}
/**
* create a library of cell styles /**
*/ * create a library of cell styles
private static Map<String, CellStyle> createStyles(Workbook wb){ */
Map<String, CellStyle> styles = new HashMap<String, CellStyle>(); private static Map<String, CellStyle> createStyles(Workbook wb){
DataFormat df = wb.createDataFormat(); Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
DataFormat df = wb.createDataFormat();
CellStyle style;
Font headerFont = wb.createFont(); CellStyle style;
headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD); Font headerFont = wb.createFont();
style = createBorderedStyle(wb); headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
style.setAlignment(CellStyle.ALIGN_CENTER); style = createBorderedStyle(wb);
style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex()); style.setAlignment(CellStyle.ALIGN_CENTER);
style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex());
style.setFont(headerFont); style.setFillPattern(CellStyle.SOLID_FOREGROUND);
styles.put("header", style); style.setFont(headerFont);
styles.put("header", style);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_CENTER); style = createBorderedStyle(wb);
style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex()); style.setAlignment(CellStyle.ALIGN_CENTER);
style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex());
style.setFont(headerFont); style.setFillPattern(CellStyle.SOLID_FOREGROUND);
style.setDataFormat(df.getFormat("d-mmm")); style.setFont(headerFont);
styles.put("header_date", style); style.setDataFormat(df.getFormat("d-mmm"));
styles.put("header_date", style);
Font font1 = wb.createFont();
font1.setBoldweight(Font.BOLDWEIGHT_BOLD); Font font1 = wb.createFont();
style = createBorderedStyle(wb); font1.setBoldweight(Font.BOLDWEIGHT_BOLD);
style.setAlignment(CellStyle.ALIGN_LEFT); style = createBorderedStyle(wb);
style.setFont(font1); style.setAlignment(CellStyle.ALIGN_LEFT);
styles.put("cell_b", style); style.setFont(font1);
styles.put("cell_b", style);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_CENTER); style = createBorderedStyle(wb);
style.setFont(font1); style.setAlignment(CellStyle.ALIGN_CENTER);
styles.put("cell_b_centered", style); style.setFont(font1);
styles.put("cell_b_centered", style);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_RIGHT); style = createBorderedStyle(wb);
style.setFont(font1); style.setAlignment(CellStyle.ALIGN_RIGHT);
style.setDataFormat(df.getFormat("d-mmm")); style.setFont(font1);
styles.put("cell_b_date", style); style.setDataFormat(df.getFormat("d-mmm"));
styles.put("cell_b_date", style);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_RIGHT); style = createBorderedStyle(wb);
style.setFont(font1); style.setAlignment(CellStyle.ALIGN_RIGHT);
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); style.setFont(font1);
style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
style.setDataFormat(df.getFormat("d-mmm")); style.setFillPattern(CellStyle.SOLID_FOREGROUND);
styles.put("cell_g", style); style.setDataFormat(df.getFormat("d-mmm"));
styles.put("cell_g", style);
Font font2 = wb.createFont();
font2.setColor(IndexedColors.BLUE.getIndex()); Font font2 = wb.createFont();
font2.setBoldweight(Font.BOLDWEIGHT_BOLD); font2.setColor(IndexedColors.BLUE.getIndex());
style = createBorderedStyle(wb); font2.setBoldweight(Font.BOLDWEIGHT_BOLD);
style.setAlignment(CellStyle.ALIGN_LEFT); style = createBorderedStyle(wb);
style.setFont(font2); style.setAlignment(CellStyle.ALIGN_LEFT);
styles.put("cell_bb", style); style.setFont(font2);
styles.put("cell_bb", style);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_RIGHT); style = createBorderedStyle(wb);
style.setFont(font1); style.setAlignment(CellStyle.ALIGN_RIGHT);
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); style.setFont(font1);
style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
style.setDataFormat(df.getFormat("d-mmm")); style.setFillPattern(CellStyle.SOLID_FOREGROUND);
styles.put("cell_bg", style); style.setDataFormat(df.getFormat("d-mmm"));
styles.put("cell_bg", style);
Font font3 = wb.createFont();
font3.setFontHeightInPoints((short)14); Font font3 = wb.createFont();
font3.setColor(IndexedColors.DARK_BLUE.getIndex()); font3.setFontHeightInPoints((short)14);
font3.setBoldweight(Font.BOLDWEIGHT_BOLD); font3.setColor(IndexedColors.DARK_BLUE.getIndex());
style = createBorderedStyle(wb); font3.setBoldweight(Font.BOLDWEIGHT_BOLD);
style.setAlignment(CellStyle.ALIGN_LEFT); style = createBorderedStyle(wb);
style.setFont(font3); style.setAlignment(CellStyle.ALIGN_LEFT);
style.setWrapText(true); style.setFont(font3);
styles.put("cell_h", style); style.setWrapText(true);
styles.put("cell_h", style);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_LEFT); style = createBorderedStyle(wb);
style.setWrapText(true); style.setAlignment(CellStyle.ALIGN_LEFT);
styles.put("cell_normal", style); style.setWrapText(true);
styles.put("cell_normal", style);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_CENTER); style = createBorderedStyle(wb);
style.setWrapText(true); style.setAlignment(CellStyle.ALIGN_CENTER);
styles.put("cell_normal_centered", style); style.setWrapText(true);
styles.put("cell_normal_centered", style);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_RIGHT); style = createBorderedStyle(wb);
style.setWrapText(true); style.setAlignment(CellStyle.ALIGN_RIGHT);
style.setDataFormat(df.getFormat("d-mmm")); style.setWrapText(true);
styles.put("cell_normal_date", style); style.setDataFormat(df.getFormat("d-mmm"));
styles.put("cell_normal_date", style);
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_LEFT); style = createBorderedStyle(wb);
style.setIndention((short)1); style.setAlignment(CellStyle.ALIGN_LEFT);
style.setWrapText(true); style.setIndention((short)1);
styles.put("cell_indented", style); style.setWrapText(true);
styles.put("cell_indented", style);
style = createBorderedStyle(wb);
style.setFillForegroundColor(IndexedColors.BLUE.getIndex()); style = createBorderedStyle(wb);
style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.BLUE.getIndex());
styles.put("cell_blue", style); style.setFillPattern(CellStyle.SOLID_FOREGROUND);
styles.put("cell_blue", style);
return styles;
} return styles;
}
private static CellStyle createBorderedStyle(Workbook wb){
CellStyle style = wb.createCellStyle(); private static CellStyle createBorderedStyle(Workbook wb){
style.setBorderRight(CellStyle.BORDER_THIN); CellStyle style = wb.createCellStyle();
style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderRight(CellStyle.BORDER_THIN);
style.setBorderBottom(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex());
style.setBottomBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderBottom(CellStyle.BORDER_THIN);
style.setBorderLeft(CellStyle.BORDER_THIN); style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN);
style.setBorderTop(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
style.setTopBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderTop(CellStyle.BORDER_THIN);
return style; style.setTopBorderColor(IndexedColors.BLACK.getIndex());
} return style;
} }
}

View File

@ -1,242 +1,243 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership. this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0 The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.ss.examples;
package org.apache.poi.ss.examples;
import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import java.io.FileOutputStream;
import java.util.Calendar; import java.io.FileOutputStream;
import java.util.Map; import java.util.Calendar;
import java.util.HashMap; import java.util.Map;
import java.util.HashMap;
/**
* A monthly calendar created using Apache POI. Each month is on a separate sheet. /**
* <pre> * A monthly calendar created using Apache POI. Each month is on a separate sheet.
* Usage: * <pre>
* CalendarDemo -xls|xlsx <year> * Usage:
* </pre> * CalendarDemo -xls|xlsx <year>
* * </pre>
* @author Yegor Kozlov *
*/ * @author Yegor Kozlov
public class CalendarDemo { */
public class CalendarDemo {
private static final String[] days = {
"Sunday", "Monday", "Tuesday", private static final String[] days = {
"Wednesday", "Thursday", "Friday", "Saturday"}; "Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"};
private static final String[] months = {
"January", "February", "March","April", "May", "June","July", "August", private static final String[] months = {
"September","October", "November", "December"}; "January", "February", "March","April", "May", "June","July", "August",
"September","October", "November", "December"};
public static void main(String[] args) throws Exception {
public static void main(String[] args) throws Exception {
Calendar calendar = Calendar.getInstance();
boolean xlsx = true; Calendar calendar = Calendar.getInstance();
for (int i = 0; i < args.length; i++) { boolean xlsx = true;
if(args[i].charAt(0) == '-'){ for (int i = 0; i < args.length; i++) {
xlsx = args[i].equals("-xlsx"); if(args[i].charAt(0) == '-'){
} else { xlsx = args[i].equals("-xlsx");
calendar.set(Calendar.YEAR, Integer.parseInt(args[i])); } else {
} calendar.set(Calendar.YEAR, Integer.parseInt(args[i]));
} }
int year = calendar.get(Calendar.YEAR); }
int year = calendar.get(Calendar.YEAR);
Workbook wb = xlsx ? new XSSFWorkbook() : new HSSFWorkbook();
Workbook wb = xlsx ? new XSSFWorkbook() : new HSSFWorkbook();
Map<String, CellStyle> styles = createStyles(wb);
Map<String, CellStyle> styles = createStyles(wb);
for (int month = 0; month < 12; month++) {
calendar.set(Calendar.MONTH, month); for (int month = 0; month < 12; month++) {
calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.MONTH, month);
//create a sheet for each month calendar.set(Calendar.DAY_OF_MONTH, 1);
Sheet sheet = wb.createSheet(months[month]); //create a sheet for each month
Sheet sheet = wb.createSheet(months[month]);
//turn off gridlines
sheet.setDisplayGridlines(false); //turn off gridlines
sheet.setPrintGridlines(false); sheet.setDisplayGridlines(false);
sheet.setFitToPage(true); sheet.setPrintGridlines(false);
sheet.setHorizontallyCenter(true); sheet.setFitToPage(true);
PrintSetup printSetup = sheet.getPrintSetup(); sheet.setHorizontallyCenter(true);
printSetup.setLandscape(true); PrintSetup printSetup = sheet.getPrintSetup();
printSetup.setLandscape(true);
//the following three statements are required only for HSSF
sheet.setAutobreaks(true); //the following three statements are required only for HSSF
printSetup.setFitHeight((short)1); sheet.setAutobreaks(true);
printSetup.setFitWidth((short)1); printSetup.setFitHeight((short)1);
printSetup.setFitWidth((short)1);
//the header row: centered text in 48pt font
Row headerRow = sheet.createRow(0); //the header row: centered text in 48pt font
headerRow.setHeightInPoints(80); Row headerRow = sheet.createRow(0);
Cell titleCell = headerRow.createCell(0); headerRow.setHeightInPoints(80);
titleCell.setCellValue(months[month] + " " + year); Cell titleCell = headerRow.createCell(0);
titleCell.setCellStyle(styles.get("title")); titleCell.setCellValue(months[month] + " " + year);
sheet.addMergedRegion(CellRangeAddress.valueOf("$A$1:$N$1")); titleCell.setCellStyle(styles.get("title"));
sheet.addMergedRegion(CellRangeAddress.valueOf("$A$1:$N$1"));
//header with month titles
Row monthRow = sheet.createRow(1); //header with month titles
for (int i = 0; i < days.length; i++) { Row monthRow = sheet.createRow(1);
//set column widths, the width is measured in units of 1/256th of a character width for (int i = 0; i < days.length; i++) {
sheet.setColumnWidth(i*2, 5*256); //the column is 5 characters wide //set column widths, the width is measured in units of 1/256th of a character width
sheet.setColumnWidth(i*2 + 1, 13*256); //the column is 13 characters wide sheet.setColumnWidth(i*2, 5*256); //the column is 5 characters wide
sheet.addMergedRegion(new CellRangeAddress(1, 1, i*2, i*2+1)); sheet.setColumnWidth(i*2 + 1, 13*256); //the column is 13 characters wide
Cell monthCell = monthRow.createCell(i*2); sheet.addMergedRegion(new CellRangeAddress(1, 1, i*2, i*2+1));
monthCell.setCellValue(days[i]); Cell monthCell = monthRow.createCell(i*2);
monthCell.setCellStyle(styles.get("month")); monthCell.setCellValue(days[i]);
} monthCell.setCellStyle(styles.get("month"));
}
int cnt = 1, day=1;
int rownum = 2; int cnt = 1, day=1;
for (int j = 0; j < 6; j++) { int rownum = 2;
Row row = sheet.createRow(rownum++); for (int j = 0; j < 6; j++) {
row.setHeightInPoints(100); Row row = sheet.createRow(rownum++);
for (int i = 0; i < days.length; i++) { row.setHeightInPoints(100);
Cell dayCell_1 = row.createCell(i*2); for (int i = 0; i < days.length; i++) {
Cell dayCell_2 = row.createCell(i*2 + 1); Cell dayCell_1 = row.createCell(i*2);
Cell dayCell_2 = row.createCell(i*2 + 1);
int day_of_week = calendar.get(Calendar.DAY_OF_WEEK);
if(cnt >= day_of_week && calendar.get(Calendar.MONTH) == month) { int day_of_week = calendar.get(Calendar.DAY_OF_WEEK);
dayCell_1.setCellValue(day); if(cnt >= day_of_week && calendar.get(Calendar.MONTH) == month) {
calendar.set(Calendar.DAY_OF_MONTH, ++day); dayCell_1.setCellValue(day);
calendar.set(Calendar.DAY_OF_MONTH, ++day);
if(i == 0 || i == days.length-1) {
dayCell_1.setCellStyle(styles.get("weekend_left")); if(i == 0 || i == days.length-1) {
dayCell_2.setCellStyle(styles.get("weekend_right")); dayCell_1.setCellStyle(styles.get("weekend_left"));
} else { dayCell_2.setCellStyle(styles.get("weekend_right"));
dayCell_1.setCellStyle(styles.get("workday_left")); } else {
dayCell_2.setCellStyle(styles.get("workday_right")); dayCell_1.setCellStyle(styles.get("workday_left"));
} dayCell_2.setCellStyle(styles.get("workday_right"));
} else { }
dayCell_1.setCellStyle(styles.get("grey_left")); } else {
dayCell_2.setCellStyle(styles.get("grey_right")); dayCell_1.setCellStyle(styles.get("grey_left"));
} dayCell_2.setCellStyle(styles.get("grey_right"));
cnt++; }
} cnt++;
if(calendar.get(Calendar.MONTH) > month) break; }
} if(calendar.get(Calendar.MONTH) > month) break;
} }
}
// Write the output to a file
String file = "calendar.xls"; // Write the output to a file
if(wb instanceof XSSFWorkbook) file += "x"; String file = "calendar.xls";
FileOutputStream out = new FileOutputStream(file); if(wb instanceof XSSFWorkbook) file += "x";
wb.write(out); FileOutputStream out = new FileOutputStream(file);
out.close(); wb.write(out);
} out.close();
}
/**
* cell styles used for formatting calendar sheets /**
*/ * cell styles used for formatting calendar sheets
private static Map<String, CellStyle> createStyles(Workbook wb){ */
Map<String, CellStyle> styles = new HashMap<String, CellStyle>(); private static Map<String, CellStyle> createStyles(Workbook wb){
Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
short borderColor = IndexedColors.GREY_50_PERCENT.getIndex();
short borderColor = IndexedColors.GREY_50_PERCENT.getIndex();
CellStyle style;
Font titleFont = wb.createFont(); CellStyle style;
titleFont.setFontHeightInPoints((short)48); Font titleFont = wb.createFont();
titleFont.setColor(IndexedColors.DARK_BLUE.getIndex()); titleFont.setFontHeightInPoints((short)48);
style = wb.createCellStyle(); titleFont.setColor(IndexedColors.DARK_BLUE.getIndex());
style.setAlignment(CellStyle.ALIGN_CENTER); style = wb.createCellStyle();
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setAlignment(CellStyle.ALIGN_CENTER);
style.setFont(titleFont); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
styles.put("title", style); style.setFont(titleFont);
styles.put("title", style);
Font monthFont = wb.createFont();
monthFont.setFontHeightInPoints((short)12); Font monthFont = wb.createFont();
monthFont.setColor(IndexedColors.WHITE.getIndex()); monthFont.setFontHeightInPoints((short)12);
monthFont.setBoldweight(Font.BOLDWEIGHT_BOLD); monthFont.setColor(IndexedColors.WHITE.getIndex());
style = wb.createCellStyle(); monthFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
style.setAlignment(CellStyle.ALIGN_CENTER); style = wb.createCellStyle();
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setAlignment(CellStyle.ALIGN_CENTER);
style.setFillForegroundColor(IndexedColors.DARK_BLUE.getIndex()); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.DARK_BLUE.getIndex());
style.setFont(monthFont); style.setFillPattern(CellStyle.SOLID_FOREGROUND);
styles.put("month", style); style.setFont(monthFont);
styles.put("month", style);
Font dayFont = wb.createFont();
dayFont.setFontHeightInPoints((short)14); Font dayFont = wb.createFont();
dayFont.setBoldweight(Font.BOLDWEIGHT_BOLD); dayFont.setFontHeightInPoints((short)14);
style = wb.createCellStyle(); dayFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
style.setAlignment(CellStyle.ALIGN_LEFT); style = wb.createCellStyle();
style.setVerticalAlignment(CellStyle.VERTICAL_TOP); style.setAlignment(CellStyle.ALIGN_LEFT);
style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex()); style.setVerticalAlignment(CellStyle.VERTICAL_TOP);
style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex());
style.setBorderLeft(CellStyle.BORDER_THIN); style.setFillPattern(CellStyle.SOLID_FOREGROUND);
style.setLeftBorderColor(borderColor); style.setBorderLeft(CellStyle.BORDER_THIN);
style.setBorderBottom(CellStyle.BORDER_THIN); style.setLeftBorderColor(borderColor);
style.setBottomBorderColor(borderColor); style.setBorderBottom(CellStyle.BORDER_THIN);
style.setFont(dayFont); style.setBottomBorderColor(borderColor);
styles.put("weekend_left", style); style.setFont(dayFont);
styles.put("weekend_left", style);
style = wb.createCellStyle();
style.setAlignment(CellStyle.ALIGN_CENTER); style = wb.createCellStyle();
style.setVerticalAlignment(CellStyle.VERTICAL_TOP); style.setAlignment(CellStyle.ALIGN_CENTER);
style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex()); style.setVerticalAlignment(CellStyle.VERTICAL_TOP);
style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex());
style.setBorderRight(CellStyle.BORDER_THIN); style.setFillPattern(CellStyle.SOLID_FOREGROUND);
style.setRightBorderColor(borderColor); style.setBorderRight(CellStyle.BORDER_THIN);
style.setBorderBottom(CellStyle.BORDER_THIN); style.setRightBorderColor(borderColor);
style.setBottomBorderColor(borderColor); style.setBorderBottom(CellStyle.BORDER_THIN);
styles.put("weekend_right", style); style.setBottomBorderColor(borderColor);
styles.put("weekend_right", style);
style = wb.createCellStyle();
style.setAlignment(CellStyle.ALIGN_LEFT); style = wb.createCellStyle();
style.setVerticalAlignment(CellStyle.VERTICAL_TOP); style.setAlignment(CellStyle.ALIGN_LEFT);
style.setBorderLeft(CellStyle.BORDER_THIN); style.setVerticalAlignment(CellStyle.VERTICAL_TOP);
style.setFillForegroundColor(IndexedColors.WHITE.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN);
style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.WHITE.getIndex());
style.setLeftBorderColor(borderColor); style.setFillPattern(CellStyle.SOLID_FOREGROUND);
style.setBorderBottom(CellStyle.BORDER_THIN); style.setLeftBorderColor(borderColor);
style.setBottomBorderColor(borderColor); style.setBorderBottom(CellStyle.BORDER_THIN);
style.setFont(dayFont); style.setBottomBorderColor(borderColor);
styles.put("workday_left", style); style.setFont(dayFont);
styles.put("workday_left", style);
style = wb.createCellStyle();
style.setAlignment(CellStyle.ALIGN_CENTER); style = wb.createCellStyle();
style.setVerticalAlignment(CellStyle.VERTICAL_TOP); style.setAlignment(CellStyle.ALIGN_CENTER);
style.setFillForegroundColor(IndexedColors.WHITE.getIndex()); style.setVerticalAlignment(CellStyle.VERTICAL_TOP);
style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.WHITE.getIndex());
style.setBorderRight(CellStyle.BORDER_THIN); style.setFillPattern(CellStyle.SOLID_FOREGROUND);
style.setRightBorderColor(borderColor); style.setBorderRight(CellStyle.BORDER_THIN);
style.setBorderBottom(CellStyle.BORDER_THIN); style.setRightBorderColor(borderColor);
style.setBottomBorderColor(borderColor); style.setBorderBottom(CellStyle.BORDER_THIN);
styles.put("workday_right", style); style.setBottomBorderColor(borderColor);
styles.put("workday_right", style);
style = wb.createCellStyle();
style.setBorderLeft(CellStyle.BORDER_THIN); style = wb.createCellStyle();
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN);
style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
style.setBorderBottom(CellStyle.BORDER_THIN); style.setFillPattern(CellStyle.SOLID_FOREGROUND);
style.setBottomBorderColor(borderColor); style.setBorderBottom(CellStyle.BORDER_THIN);
styles.put("grey_left", style); style.setBottomBorderColor(borderColor);
styles.put("grey_left", style);
style = wb.createCellStyle();
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); style = wb.createCellStyle();
style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
style.setBorderRight(CellStyle.BORDER_THIN); style.setFillPattern(CellStyle.SOLID_FOREGROUND);
style.setRightBorderColor(borderColor); style.setBorderRight(CellStyle.BORDER_THIN);
style.setBorderBottom(CellStyle.BORDER_THIN); style.setRightBorderColor(borderColor);
style.setBottomBorderColor(borderColor); style.setBorderBottom(CellStyle.BORDER_THIN);
styles.put("grey_right", style); style.setBottomBorderColor(borderColor);
styles.put("grey_right", style);
return styles;
} return styles;
} }
}

View File

@ -1,304 +1,305 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership. this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0 The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.ss.examples;
package org.apache.poi.ss.examples;
import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import java.util.Map;
import java.util.HashMap; import java.util.Map;
import java.io.FileOutputStream; import java.util.HashMap;
import java.io.FileOutputStream;
/**
* Simple Loan Calculator. Demonstrates advance usage of cell formulas and named ranges. /**
* * Simple Loan Calculator. Demonstrates advance usage of cell formulas and named ranges.
* Usage: *
* LoanCalculator -xls|xlsx * Usage:
* * LoanCalculator -xls|xlsx
* @author Yegor Kozlov *
*/ * @author Yegor Kozlov
public class LoanCalculator { */
public class LoanCalculator {
public static void main(String[] args) throws Exception {
Workbook wb; public static void main(String[] args) throws Exception {
Workbook wb;
if(args.length > 0 && args[0].equals("-xls")) wb = new HSSFWorkbook();
else wb = new XSSFWorkbook(); if(args.length > 0 && args[0].equals("-xls")) wb = new HSSFWorkbook();
else wb = new XSSFWorkbook();
Map<String, CellStyle> styles = createStyles(wb);
Sheet sheet = wb.createSheet("Loan Calculator"); Map<String, CellStyle> styles = createStyles(wb);
sheet.setPrintGridlines(false); Sheet sheet = wb.createSheet("Loan Calculator");
sheet.setDisplayGridlines(false); sheet.setPrintGridlines(false);
sheet.setDisplayGridlines(false);
PrintSetup printSetup = sheet.getPrintSetup();
printSetup.setLandscape(true); PrintSetup printSetup = sheet.getPrintSetup();
sheet.setFitToPage(true); printSetup.setLandscape(true);
sheet.setHorizontallyCenter(true); sheet.setFitToPage(true);
sheet.setHorizontallyCenter(true);
sheet.setColumnWidth(0, 3*256);
sheet.setColumnWidth(1, 3*256); sheet.setColumnWidth(0, 3*256);
sheet.setColumnWidth(2, 11*256); sheet.setColumnWidth(1, 3*256);
sheet.setColumnWidth(3, 14*256); sheet.setColumnWidth(2, 11*256);
sheet.setColumnWidth(4, 14*256); sheet.setColumnWidth(3, 14*256);
sheet.setColumnWidth(5, 14*256); sheet.setColumnWidth(4, 14*256);
sheet.setColumnWidth(6, 14*256); sheet.setColumnWidth(5, 14*256);
sheet.setColumnWidth(6, 14*256);
createNames(wb);
createNames(wb);
Row titleRow = sheet.createRow(0);
titleRow.setHeightInPoints(35); Row titleRow = sheet.createRow(0);
for (int i = 1; i <= 7; i++) { titleRow.setHeightInPoints(35);
titleRow.createCell(i).setCellStyle(styles.get("title")); for (int i = 1; i <= 7; i++) {
} titleRow.createCell(i).setCellStyle(styles.get("title"));
Cell titleCell = titleRow.getCell(2); }
titleCell.setCellValue("Simple Loan Calculator"); Cell titleCell = titleRow.getCell(2);
sheet.addMergedRegion(CellRangeAddress.valueOf("$C$1:$H$1")); titleCell.setCellValue("Simple Loan Calculator");
sheet.addMergedRegion(CellRangeAddress.valueOf("$C$1:$H$1"));
Row row = sheet.createRow(2);
Cell cell = row.createCell(4); Row row = sheet.createRow(2);
cell.setCellValue("Enter values"); Cell cell = row.createCell(4);
cell.setCellStyle(styles.get("item_right")); cell.setCellValue("Enter values");
cell.setCellStyle(styles.get("item_right"));
row = sheet.createRow(3);
cell = row.createCell(2); row = sheet.createRow(3);
cell.setCellValue("Loan amount"); cell = row.createCell(2);
cell.setCellStyle(styles.get("item_left")); cell.setCellValue("Loan amount");
cell = row.createCell(4); cell.setCellStyle(styles.get("item_left"));
cell.setCellStyle(styles.get("input_$")); cell = row.createCell(4);
cell.setAsActiveCell(); cell.setCellStyle(styles.get("input_$"));
cell.setAsActiveCell();
row = sheet.createRow(4);
cell = row.createCell(2); row = sheet.createRow(4);
cell.setCellValue("Annual interest rate"); cell = row.createCell(2);
cell.setCellStyle(styles.get("item_left")); cell.setCellValue("Annual interest rate");
cell = row.createCell(4); cell.setCellStyle(styles.get("item_left"));
cell.setCellStyle(styles.get("input_%")); cell = row.createCell(4);
cell.setCellStyle(styles.get("input_%"));
row = sheet.createRow(5);
cell = row.createCell(2); row = sheet.createRow(5);
cell.setCellValue("Loan period in years"); cell = row.createCell(2);
cell.setCellStyle(styles.get("item_left")); cell.setCellValue("Loan period in years");
cell = row.createCell(4); cell.setCellStyle(styles.get("item_left"));
cell.setCellStyle(styles.get("input_i")); cell = row.createCell(4);
cell.setCellStyle(styles.get("input_i"));
row = sheet.createRow(6);
cell = row.createCell(2); row = sheet.createRow(6);
cell.setCellValue("Start date of loan"); cell = row.createCell(2);
cell.setCellStyle(styles.get("item_left")); cell.setCellValue("Start date of loan");
cell = row.createCell(4); cell.setCellStyle(styles.get("item_left"));
cell.setCellStyle(styles.get("input_d")); cell = row.createCell(4);
cell.setCellStyle(styles.get("input_d"));
row = sheet.createRow(8);
cell = row.createCell(2); row = sheet.createRow(8);
cell.setCellValue("Monthly payment"); cell = row.createCell(2);
cell.setCellStyle(styles.get("item_left")); cell.setCellValue("Monthly payment");
cell = row.createCell(4); cell.setCellStyle(styles.get("item_left"));
cell.setCellFormula("IF(Values_Entered,Monthly_Payment,\"\")"); cell = row.createCell(4);
cell.setCellStyle(styles.get("formula_$")); cell.setCellFormula("IF(Values_Entered,Monthly_Payment,\"\")");
cell.setCellStyle(styles.get("formula_$"));
row = sheet.createRow(9);
cell = row.createCell(2); row = sheet.createRow(9);
cell.setCellValue("Number of payments"); cell = row.createCell(2);
cell.setCellStyle(styles.get("item_left")); cell.setCellValue("Number of payments");
cell = row.createCell(4); cell.setCellStyle(styles.get("item_left"));
cell.setCellFormula("IF(Values_Entered,Loan_Years*12,\"\")"); cell = row.createCell(4);
cell.setCellStyle(styles.get("formula_i")); cell.setCellFormula("IF(Values_Entered,Loan_Years*12,\"\")");
cell.setCellStyle(styles.get("formula_i"));
row = sheet.createRow(10);
cell = row.createCell(2); row = sheet.createRow(10);
cell.setCellValue("Total interest"); cell = row.createCell(2);
cell.setCellStyle(styles.get("item_left")); cell.setCellValue("Total interest");
cell = row.createCell(4); cell.setCellStyle(styles.get("item_left"));
cell.setCellFormula("IF(Values_Entered,Total_Cost-Loan_Amount,\"\")"); cell = row.createCell(4);
cell.setCellStyle(styles.get("formula_$")); cell.setCellFormula("IF(Values_Entered,Total_Cost-Loan_Amount,\"\")");
cell.setCellStyle(styles.get("formula_$"));
row = sheet.createRow(11);
cell = row.createCell(2); row = sheet.createRow(11);
cell.setCellValue("Total cost of loan"); cell = row.createCell(2);
cell.setCellStyle(styles.get("item_left")); cell.setCellValue("Total cost of loan");
cell = row.createCell(4); cell.setCellStyle(styles.get("item_left"));
cell.setCellFormula("IF(Values_Entered,Monthly_Payment*Number_of_Payments,\"\")"); cell = row.createCell(4);
cell.setCellStyle(styles.get("formula_$")); cell.setCellFormula("IF(Values_Entered,Monthly_Payment*Number_of_Payments,\"\")");
cell.setCellStyle(styles.get("formula_$"));
// Write the output to a file
String file = "loan-calculator.xls"; // Write the output to a file
if(wb instanceof XSSFWorkbook) file += "x"; String file = "loan-calculator.xls";
FileOutputStream out = new FileOutputStream(file); if(wb instanceof XSSFWorkbook) file += "x";
wb.write(out); FileOutputStream out = new FileOutputStream(file);
out.close(); wb.write(out);
} out.close();
}
/**
* cell styles used for formatting calendar sheets /**
*/ * cell styles used for formatting calendar sheets
private static Map<String, CellStyle> createStyles(Workbook wb){ */
Map<String, CellStyle> styles = new HashMap<String, CellStyle>(); private static Map<String, CellStyle> createStyles(Workbook wb){
Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
CellStyle style;
Font titleFont = wb.createFont(); CellStyle style;
titleFont.setFontHeightInPoints((short)14); Font titleFont = wb.createFont();
titleFont.setFontName("Trebuchet MS"); titleFont.setFontHeightInPoints((short)14);
style = wb.createCellStyle(); titleFont.setFontName("Trebuchet MS");
style.setFont(titleFont); style = wb.createCellStyle();
style.setBorderBottom(CellStyle.BORDER_DOTTED); style.setFont(titleFont);
style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderBottom(CellStyle.BORDER_DOTTED);
styles.put("title", style); style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
styles.put("title", style);
Font itemFont = wb.createFont();
itemFont.setFontHeightInPoints((short)9); Font itemFont = wb.createFont();
itemFont.setFontName("Trebuchet MS"); itemFont.setFontHeightInPoints((short)9);
style = wb.createCellStyle(); itemFont.setFontName("Trebuchet MS");
style.setAlignment(CellStyle.ALIGN_LEFT); style = wb.createCellStyle();
style.setFont(itemFont); style.setAlignment(CellStyle.ALIGN_LEFT);
styles.put("item_left", style); style.setFont(itemFont);
styles.put("item_left", style);
style = wb.createCellStyle();
style.setAlignment(CellStyle.ALIGN_RIGHT); style = wb.createCellStyle();
style.setFont(itemFont); style.setAlignment(CellStyle.ALIGN_RIGHT);
styles.put("item_right", style); style.setFont(itemFont);
styles.put("item_right", style);
style = wb.createCellStyle();
style.setAlignment(CellStyle.ALIGN_RIGHT); style = wb.createCellStyle();
style.setFont(itemFont); style.setAlignment(CellStyle.ALIGN_RIGHT);
style.setBorderRight(CellStyle.BORDER_DOTTED); style.setFont(itemFont);
style.setRightBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderRight(CellStyle.BORDER_DOTTED);
style.setBorderBottom(CellStyle.BORDER_DOTTED); style.setRightBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderBottom(CellStyle.BORDER_DOTTED);
style.setBorderLeft(CellStyle.BORDER_DOTTED); style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setLeftBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderLeft(CellStyle.BORDER_DOTTED);
style.setBorderTop(CellStyle.BORDER_DOTTED); style.setLeftBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setTopBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderTop(CellStyle.BORDER_DOTTED);
style.setDataFormat(wb.createDataFormat().getFormat("_($* #,##0.00_);_($* (#,##0.00);_($* \"-\"??_);_(@_)")); style.setTopBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
styles.put("input_$", style); style.setDataFormat(wb.createDataFormat().getFormat("_($* #,##0.00_);_($* (#,##0.00);_($* \"-\"??_);_(@_)"));
styles.put("input_$", style);
style = wb.createCellStyle();
style.setAlignment(CellStyle.ALIGN_RIGHT); style = wb.createCellStyle();
style.setFont(itemFont); style.setAlignment(CellStyle.ALIGN_RIGHT);
style.setBorderRight(CellStyle.BORDER_DOTTED); style.setFont(itemFont);
style.setRightBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderRight(CellStyle.BORDER_DOTTED);
style.setBorderBottom(CellStyle.BORDER_DOTTED); style.setRightBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderBottom(CellStyle.BORDER_DOTTED);
style.setBorderLeft(CellStyle.BORDER_DOTTED); style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setLeftBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderLeft(CellStyle.BORDER_DOTTED);
style.setBorderTop(CellStyle.BORDER_DOTTED); style.setLeftBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setTopBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderTop(CellStyle.BORDER_DOTTED);
style.setDataFormat(wb.createDataFormat().getFormat("0.000%")); style.setTopBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
styles.put("input_%", style); style.setDataFormat(wb.createDataFormat().getFormat("0.000%"));
styles.put("input_%", style);
style = wb.createCellStyle();
style.setAlignment(CellStyle.ALIGN_RIGHT); style = wb.createCellStyle();
style.setFont(itemFont); style.setAlignment(CellStyle.ALIGN_RIGHT);
style.setBorderRight(CellStyle.BORDER_DOTTED); style.setFont(itemFont);
style.setRightBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderRight(CellStyle.BORDER_DOTTED);
style.setBorderBottom(CellStyle.BORDER_DOTTED); style.setRightBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderBottom(CellStyle.BORDER_DOTTED);
style.setBorderLeft(CellStyle.BORDER_DOTTED); style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setLeftBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderLeft(CellStyle.BORDER_DOTTED);
style.setBorderTop(CellStyle.BORDER_DOTTED); style.setLeftBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setTopBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderTop(CellStyle.BORDER_DOTTED);
style.setDataFormat(wb.createDataFormat().getFormat("0")); style.setTopBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
styles.put("input_i", style); style.setDataFormat(wb.createDataFormat().getFormat("0"));
styles.put("input_i", style);
style = wb.createCellStyle();
style.setAlignment(CellStyle.ALIGN_CENTER); style = wb.createCellStyle();
style.setFont(itemFont); style.setAlignment(CellStyle.ALIGN_CENTER);
style.setDataFormat(wb.createDataFormat().getFormat("m/d/yy")); style.setFont(itemFont);
styles.put("input_d", style); style.setDataFormat(wb.createDataFormat().getFormat("m/d/yy"));
styles.put("input_d", style);
style = wb.createCellStyle();
style.setAlignment(CellStyle.ALIGN_RIGHT); style = wb.createCellStyle();
style.setFont(itemFont); style.setAlignment(CellStyle.ALIGN_RIGHT);
style.setBorderRight(CellStyle.BORDER_DOTTED); style.setFont(itemFont);
style.setRightBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderRight(CellStyle.BORDER_DOTTED);
style.setBorderBottom(CellStyle.BORDER_DOTTED); style.setRightBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderBottom(CellStyle.BORDER_DOTTED);
style.setBorderLeft(CellStyle.BORDER_DOTTED); style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setLeftBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderLeft(CellStyle.BORDER_DOTTED);
style.setBorderTop(CellStyle.BORDER_DOTTED); style.setLeftBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setTopBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderTop(CellStyle.BORDER_DOTTED);
style.setDataFormat(wb.createDataFormat().getFormat("$##,##0.00")); style.setTopBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setBorderBottom(CellStyle.BORDER_DOTTED); style.setDataFormat(wb.createDataFormat().getFormat("$##,##0.00"));
style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderBottom(CellStyle.BORDER_DOTTED);
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
styles.put("formula_$", style); style.setFillPattern(CellStyle.SOLID_FOREGROUND);
styles.put("formula_$", style);
style = wb.createCellStyle();
style.setAlignment(CellStyle.ALIGN_RIGHT); style = wb.createCellStyle();
style.setFont(itemFont); style.setAlignment(CellStyle.ALIGN_RIGHT);
style.setBorderRight(CellStyle.BORDER_DOTTED); style.setFont(itemFont);
style.setRightBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderRight(CellStyle.BORDER_DOTTED);
style.setBorderBottom(CellStyle.BORDER_DOTTED); style.setRightBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderBottom(CellStyle.BORDER_DOTTED);
style.setBorderLeft(CellStyle.BORDER_DOTTED); style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setLeftBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderLeft(CellStyle.BORDER_DOTTED);
style.setBorderTop(CellStyle.BORDER_DOTTED); style.setLeftBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setTopBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderTop(CellStyle.BORDER_DOTTED);
style.setDataFormat(wb.createDataFormat().getFormat("0")); style.setTopBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setBorderBottom(CellStyle.BORDER_DOTTED); style.setDataFormat(wb.createDataFormat().getFormat("0"));
style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setBorderBottom(CellStyle.BORDER_DOTTED);
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); style.setBottomBorderColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
styles.put("formula_i", style); style.setFillPattern(CellStyle.SOLID_FOREGROUND);
styles.put("formula_i", style);
return styles;
} return styles;
}
//define named ranges for the inputs and formulas
public static void createNames(Workbook wb){ //define named ranges for the inputs and formulas
Name name; public static void createNames(Workbook wb){
Name name;
name = wb.createName();
name.setNameName("Interest_Rate"); name = wb.createName();
name.setRefersToFormula("'Loan Calculator'!$E$5"); name.setNameName("Interest_Rate");
name.setRefersToFormula("'Loan Calculator'!$E$5");
name = wb.createName();
name.setNameName("Loan_Amount"); name = wb.createName();
name.setRefersToFormula("'Loan Calculator'!$E$4"); name.setNameName("Loan_Amount");
name.setRefersToFormula("'Loan Calculator'!$E$4");
name = wb.createName();
name.setNameName("Loan_Start"); name = wb.createName();
name.setRefersToFormula("'Loan Calculator'!$E$7"); name.setNameName("Loan_Start");
name.setRefersToFormula("'Loan Calculator'!$E$7");
name = wb.createName();
name.setNameName("Loan_Years"); name = wb.createName();
name.setRefersToFormula("'Loan Calculator'!$E$6"); name.setNameName("Loan_Years");
name.setRefersToFormula("'Loan Calculator'!$E$6");
name = wb.createName();
name.setNameName("Number_of_Payments"); name = wb.createName();
name.setRefersToFormula("'Loan Calculator'!$E$10"); name.setNameName("Number_of_Payments");
name.setRefersToFormula("'Loan Calculator'!$E$10");
name = wb.createName();
name.setNameName("Monthly_Payment"); name = wb.createName();
name.setRefersToFormula("-PMT(Interest_Rate/12,Number_of_Payments,Loan_Amount)"); name.setNameName("Monthly_Payment");
name.setRefersToFormula("-PMT(Interest_Rate/12,Number_of_Payments,Loan_Amount)");
name = wb.createName();
name.setNameName("Total_Cost"); name = wb.createName();
name.setRefersToFormula("'Loan Calculator'!$E$12"); name.setNameName("Total_Cost");
name.setRefersToFormula("'Loan Calculator'!$E$12");
name = wb.createName();
name.setNameName("Total_Interest"); name = wb.createName();
name.setRefersToFormula("'Loan Calculator'!$E$11"); name.setNameName("Total_Interest");
name.setRefersToFormula("'Loan Calculator'!$E$11");
name = wb.createName();
name.setNameName("Values_Entered"); name = wb.createName();
name.setRefersToFormula("IF(Loan_Amount*Interest_Rate*Loan_Years*Loan_Start>0,1,0)"); name.setNameName("Values_Entered");
} name.setRefersToFormula("IF(Loan_Amount*Interest_Rate*Loan_Years*Loan_Start>0,1,0)");
} }
}

View File

@ -1,219 +1,220 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership. this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0 The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.ss.examples;
package org.apache.poi.ss.examples;
import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import java.util.Map;
import java.util.HashMap; import java.util.Map;
import java.io.FileOutputStream; import java.util.HashMap;
import java.io.FileOutputStream;
/**
* A weekly timesheet created using Apache POI. /**
* Usage: * A weekly timesheet created using Apache POI.
* TimesheetDemo -xls|xlsx * Usage:
* * TimesheetDemo -xls|xlsx
* @author Yegor Kozlov *
*/ * @author Yegor Kozlov
public class TimesheetDemo { */
private static final String[] titles = { public class TimesheetDemo {
"Person", "ID", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", private static final String[] titles = {
"Total\nHrs", "Overtime\nHrs", "Regular\nHrs" "Person", "ID", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun",
}; "Total\nHrs", "Overtime\nHrs", "Regular\nHrs"
};
private static Object[][] sample_data = {
{"Yegor Kozlov", "YK", 5.0, 8.0, 10.0, 5.0, 5.0, 7.0, 6.0}, private static Object[][] sample_data = {
{"Gisella Bronzetti", "GB", 4.0, 3.0, 1.0, 3.5, null, null, 4.0}, {"Yegor Kozlov", "YK", 5.0, 8.0, 10.0, 5.0, 5.0, 7.0, 6.0},
}; {"Gisella Bronzetti", "GB", 4.0, 3.0, 1.0, 3.5, null, null, 4.0},
};
public static void main(String[] args) throws Exception {
Workbook wb; public static void main(String[] args) throws Exception {
Workbook wb;
if(args.length > 0 && args[0].equals("-xls")) wb = new HSSFWorkbook();
else wb = new XSSFWorkbook(); if(args.length > 0 && args[0].equals("-xls")) wb = new HSSFWorkbook();
else wb = new XSSFWorkbook();
Map<String, CellStyle> styles = createStyles(wb);
Map<String, CellStyle> styles = createStyles(wb);
Sheet sheet = wb.createSheet("Timesheet");
PrintSetup printSetup = sheet.getPrintSetup(); Sheet sheet = wb.createSheet("Timesheet");
printSetup.setLandscape(true); PrintSetup printSetup = sheet.getPrintSetup();
sheet.setFitToPage(true); printSetup.setLandscape(true);
sheet.setHorizontallyCenter(true); sheet.setFitToPage(true);
sheet.setHorizontallyCenter(true);
//title row
Row titleRow = sheet.createRow(0); //title row
titleRow.setHeightInPoints(45); Row titleRow = sheet.createRow(0);
Cell titleCell = titleRow.createCell(0); titleRow.setHeightInPoints(45);
titleCell.setCellValue("Weekly Timesheet"); Cell titleCell = titleRow.createCell(0);
titleCell.setCellStyle(styles.get("title")); titleCell.setCellValue("Weekly Timesheet");
sheet.addMergedRegion(CellRangeAddress.valueOf("$A$1:$L$1")); titleCell.setCellStyle(styles.get("title"));
sheet.addMergedRegion(CellRangeAddress.valueOf("$A$1:$L$1"));
//header row
Row headerRow = sheet.createRow(1); //header row
headerRow.setHeightInPoints(40); Row headerRow = sheet.createRow(1);
Cell headerCell; headerRow.setHeightInPoints(40);
for (int i = 0; i < titles.length; i++) { Cell headerCell;
headerCell = headerRow.createCell(i); for (int i = 0; i < titles.length; i++) {
headerCell.setCellValue(titles[i]); headerCell = headerRow.createCell(i);
headerCell.setCellStyle(styles.get("header")); headerCell.setCellValue(titles[i]);
} headerCell.setCellStyle(styles.get("header"));
}
int rownum = 2;
for (int i = 0; i < 10; i++) { int rownum = 2;
Row row = sheet.createRow(rownum++); for (int i = 0; i < 10; i++) {
for (int j = 0; j < titles.length; j++) { Row row = sheet.createRow(rownum++);
Cell cell = row.createCell(j); for (int j = 0; j < titles.length; j++) {
if(j == 9){ Cell cell = row.createCell(j);
//the 10th cell contains sum over week days, e.g. SUM(C3:I3) if(j == 9){
String ref = "C" +rownum+ ":I" + rownum; //the 10th cell contains sum over week days, e.g. SUM(C3:I3)
cell.setCellFormula("SUM("+ref+")"); String ref = "C" +rownum+ ":I" + rownum;
cell.setCellStyle(styles.get("formula")); cell.setCellFormula("SUM("+ref+")");
} else if (j == 11){ cell.setCellStyle(styles.get("formula"));
cell.setCellFormula("J" +rownum+ "-K" + rownum); } else if (j == 11){
cell.setCellStyle(styles.get("formula")); cell.setCellFormula("J" +rownum+ "-K" + rownum);
} else { cell.setCellStyle(styles.get("formula"));
cell.setCellStyle(styles.get("cell")); } else {
} cell.setCellStyle(styles.get("cell"));
} }
} }
}
//row with totals below
Row sumRow = sheet.createRow(rownum++); //row with totals below
sumRow.setHeightInPoints(35); Row sumRow = sheet.createRow(rownum++);
Cell cell; sumRow.setHeightInPoints(35);
cell = sumRow.createCell(0); Cell cell;
cell.setCellStyle(styles.get("formula")); cell = sumRow.createCell(0);
cell = sumRow.createCell(1); cell.setCellStyle(styles.get("formula"));
cell.setCellValue("Total Hrs:"); cell = sumRow.createCell(1);
cell.setCellStyle(styles.get("formula")); cell.setCellValue("Total Hrs:");
cell.setCellStyle(styles.get("formula"));
for (int j = 2; j < 12; j++) {
cell = sumRow.createCell(j); for (int j = 2; j < 12; j++) {
String ref = (char)('A' + j) + "3:" + (char)('A' + j) + "12"; cell = sumRow.createCell(j);
cell.setCellFormula("SUM(" + ref + ")"); String ref = (char)('A' + j) + "3:" + (char)('A' + j) + "12";
if(j >= 9) cell.setCellStyle(styles.get("formula_2")); cell.setCellFormula("SUM(" + ref + ")");
else cell.setCellStyle(styles.get("formula")); if(j >= 9) cell.setCellStyle(styles.get("formula_2"));
} else cell.setCellStyle(styles.get("formula"));
rownum++; }
sumRow = sheet.createRow(rownum++); rownum++;
sumRow.setHeightInPoints(25); sumRow = sheet.createRow(rownum++);
cell = sumRow.createCell(0); sumRow.setHeightInPoints(25);
cell.setCellValue("Total Regular Hours"); cell = sumRow.createCell(0);
cell.setCellStyle(styles.get("formula")); cell.setCellValue("Total Regular Hours");
cell = sumRow.createCell(1); cell.setCellStyle(styles.get("formula"));
cell.setCellFormula("L13"); cell = sumRow.createCell(1);
cell.setCellStyle(styles.get("formula_2")); cell.setCellFormula("L13");
sumRow = sheet.createRow(rownum++); cell.setCellStyle(styles.get("formula_2"));
sumRow.setHeightInPoints(25); sumRow = sheet.createRow(rownum++);
cell = sumRow.createCell(0); sumRow.setHeightInPoints(25);
cell.setCellValue("Total Overtime Hours"); cell = sumRow.createCell(0);
cell.setCellStyle(styles.get("formula")); cell.setCellValue("Total Overtime Hours");
cell = sumRow.createCell(1); cell.setCellStyle(styles.get("formula"));
cell.setCellFormula("K13"); cell = sumRow.createCell(1);
cell.setCellStyle(styles.get("formula_2")); cell.setCellFormula("K13");
cell.setCellStyle(styles.get("formula_2"));
//set sample data
for (int i = 0; i < sample_data.length; i++) { //set sample data
Row row = sheet.getRow(2 + i); for (int i = 0; i < sample_data.length; i++) {
for (int j = 0; j < sample_data[i].length; j++) { Row row = sheet.getRow(2 + i);
if(sample_data[i][j] == null) continue; for (int j = 0; j < sample_data[i].length; j++) {
if(sample_data[i][j] == null) continue;
if(sample_data[i][j] instanceof String) {
row.getCell(j).setCellValue((String)sample_data[i][j]); if(sample_data[i][j] instanceof String) {
} else { row.getCell(j).setCellValue((String)sample_data[i][j]);
row.getCell(j).setCellValue((Double)sample_data[i][j]); } else {
} row.getCell(j).setCellValue((Double)sample_data[i][j]);
} }
} }
}
//finally set column widths, the width is measured in units of 1/256th of a character width
sheet.setColumnWidth(0, 30*256); //30 characters wide //finally set column widths, the width is measured in units of 1/256th of a character width
for (int i = 2; i < 9; i++) { sheet.setColumnWidth(0, 30*256); //30 characters wide
sheet.setColumnWidth(i, 6*256); //6 characters wide for (int i = 2; i < 9; i++) {
} sheet.setColumnWidth(i, 6*256); //6 characters wide
sheet.setColumnWidth(10, 10*256); //10 characters wide }
sheet.setColumnWidth(10, 10*256); //10 characters wide
// Write the output to a file
String file = "timesheet.xls"; // Write the output to a file
if(wb instanceof XSSFWorkbook) file += "x"; String file = "timesheet.xls";
FileOutputStream out = new FileOutputStream(file); if(wb instanceof XSSFWorkbook) file += "x";
wb.write(out); FileOutputStream out = new FileOutputStream(file);
out.close(); wb.write(out);
} out.close();
}
/**
* Create a library of cell styles /**
*/ * Create a library of cell styles
private static Map<String, CellStyle> createStyles(Workbook wb){ */
Map<String, CellStyle> styles = new HashMap<String, CellStyle>(); private static Map<String, CellStyle> createStyles(Workbook wb){
CellStyle style; Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
Font titleFont = wb.createFont(); CellStyle style;
titleFont.setFontHeightInPoints((short)18); Font titleFont = wb.createFont();
titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD); titleFont.setFontHeightInPoints((short)18);
style = wb.createCellStyle(); titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
style.setAlignment(CellStyle.ALIGN_CENTER); style = wb.createCellStyle();
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setAlignment(CellStyle.ALIGN_CENTER);
style.setFont(titleFont); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
styles.put("title", style); style.setFont(titleFont);
styles.put("title", style);
Font monthFont = wb.createFont();
monthFont.setFontHeightInPoints((short)11); Font monthFont = wb.createFont();
monthFont.setColor(IndexedColors.WHITE.getIndex()); monthFont.setFontHeightInPoints((short)11);
style = wb.createCellStyle(); monthFont.setColor(IndexedColors.WHITE.getIndex());
style.setAlignment(CellStyle.ALIGN_CENTER); style = wb.createCellStyle();
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setAlignment(CellStyle.ALIGN_CENTER);
style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setFont(monthFont); style.setFillPattern(CellStyle.SOLID_FOREGROUND);
style.setWrapText(true); style.setFont(monthFont);
styles.put("header", style); style.setWrapText(true);
styles.put("header", style);
style = wb.createCellStyle();
style.setAlignment(CellStyle.ALIGN_CENTER); style = wb.createCellStyle();
style.setWrapText(true); style.setAlignment(CellStyle.ALIGN_CENTER);
style.setBorderRight(CellStyle.BORDER_THIN); style.setWrapText(true);
style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderRight(CellStyle.BORDER_THIN);
style.setBorderLeft(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex());
style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN);
style.setBorderTop(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
style.setTopBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderTop(CellStyle.BORDER_THIN);
style.setBorderBottom(CellStyle.BORDER_THIN); style.setTopBorderColor(IndexedColors.BLACK.getIndex());
style.setBottomBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderBottom(CellStyle.BORDER_THIN);
styles.put("cell", style); style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
styles.put("cell", style);
style = wb.createCellStyle();
style.setAlignment(CellStyle.ALIGN_CENTER); style = wb.createCellStyle();
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setAlignment(CellStyle.ALIGN_CENTER);
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
style.setDataFormat(wb.createDataFormat().getFormat("0.00")); style.setFillPattern(CellStyle.SOLID_FOREGROUND);
styles.put("formula", style); style.setDataFormat(wb.createDataFormat().getFormat("0.00"));
styles.put("formula", style);
style = wb.createCellStyle();
style.setAlignment(CellStyle.ALIGN_CENTER); style = wb.createCellStyle();
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setAlignment(CellStyle.ALIGN_CENTER);
style.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.getIndex());
style.setDataFormat(wb.createDataFormat().getFormat("0.00")); style.setFillPattern(CellStyle.SOLID_FOREGROUND);
styles.put("formula_2", style); style.setDataFormat(wb.createDataFormat().getFormat("0.00"));
styles.put("formula_2", style);
return styles;
} return styles;
} }
}

View File

@ -1,29 +1,29 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!-- <!--
==================================================================== ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership. this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0 The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== ====================================================================
--> -->
<html> <html>
<head> <head>
</head> </head>
<body bgcolor="white"> <body bgcolor="white">
This package contains common internal POI code for manipulating formulas. This package contains common internal POI code for manipulating formulas.
Client applications should not refer to these classes directly. Client applications should not refer to these classes directly.
</body> </body>
</html> </html>

View File

@ -1,285 +1,285 @@
# Licensed to the Apache Software Foundation (ASF) under one or more # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with # contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. # this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0 # The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with # (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at # the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# Created by (org.apache.poi.hssf.record.formula.function.ExcelFileFormatDocFunctionExtractor) # Created by (org.apache.poi.hssf.record.formula.function.ExcelFileFormatDocFunctionExtractor)
# from source file 'excelfileformat.odt' (size=356107, md5=0x8f789cb6e75594caf068f8e193004ef4) # from source file 'excelfileformat.odt' (size=356107, md5=0x8f789cb6e75594caf068f8e193004ef4)
# #
#Columns: (index, name, minParams, maxParams, returnClass, paramClasses, isVolatile, hasFootnote ) #Columns: (index, name, minParams, maxParams, returnClass, paramClasses, isVolatile, hasFootnote )
# Built-In Sheet Functions in BIFF2 # Built-In Sheet Functions in BIFF2
0 COUNT 0 30 V R 0 COUNT 0 30 V R
1 IF 2 3 R V R R 1 IF 2 3 R V R R
2 ISNA 1 1 V V 2 ISNA 1 1 V V
3 ISERROR 1 1 V V 3 ISERROR 1 1 V V
4 SUM 0 30 V R 4 SUM 0 30 V R
5 AVERAGE 1 30 V R 5 AVERAGE 1 30 V R
6 MIN 1 30 V R 6 MIN 1 30 V R
7 MAX 1 30 V R 7 MAX 1 30 V R
8 ROW 0 1 V R 8 ROW 0 1 V R
9 COLUMN 0 1 V R 9 COLUMN 0 1 V R
10 NA 0 0 V - 10 NA 0 0 V -
11 NPV 2 30 V V R 11 NPV 2 30 V V R
12 STDEV 1 30 V R 12 STDEV 1 30 V R
13 DOLLAR 1 2 V V V 13 DOLLAR 1 2 V V V
14 FIXED 2 2 V V V x 14 FIXED 2 2 V V V x
15 SIN 1 1 V V 15 SIN 1 1 V V
16 COS 1 1 V V 16 COS 1 1 V V
17 TAN 1 1 V V 17 TAN 1 1 V V
18 ATAN 1 1 V V 18 ATAN 1 1 V V
19 PI 0 0 V - 19 PI 0 0 V -
20 SQRT 1 1 V V 20 SQRT 1 1 V V
21 EXP 1 1 V V 21 EXP 1 1 V V
22 LN 1 1 V V 22 LN 1 1 V V
23 LOG10 1 1 V V 23 LOG10 1 1 V V
24 ABS 1 1 V V 24 ABS 1 1 V V
25 INT 1 1 V V 25 INT 1 1 V V
26 SIGN 1 1 V V 26 SIGN 1 1 V V
27 ROUND 2 2 V V V 27 ROUND 2 2 V V V
28 LOOKUP 2 3 V V R R 28 LOOKUP 2 3 V V R R
29 INDEX 2 4 R R V V V 29 INDEX 2 4 R R V V V
30 REPT 2 2 V V V 30 REPT 2 2 V V V
31 MID 3 3 V V V V 31 MID 3 3 V V V V
32 LEN 1 1 V V 32 LEN 1 1 V V
33 VALUE 1 1 V V 33 VALUE 1 1 V V
34 TRUE 0 0 V - 34 TRUE 0 0 V -
35 FALSE 0 0 V - 35 FALSE 0 0 V -
36 AND 1 30 V R 36 AND 1 30 V R
37 OR 1 30 V R 37 OR 1 30 V R
38 NOT 1 1 V V 38 NOT 1 1 V V
39 MOD 2 2 V V V 39 MOD 2 2 V V V
40 DCOUNT 3 3 V R R R 40 DCOUNT 3 3 V R R R
41 DSUM 3 3 V R R R 41 DSUM 3 3 V R R R
42 DAVERAGE 3 3 V R R R 42 DAVERAGE 3 3 V R R R
43 DMIN 3 3 V R R R 43 DMIN 3 3 V R R R
44 DMAX 3 3 V R R R 44 DMAX 3 3 V R R R
45 DSTDEV 3 3 V R R R 45 DSTDEV 3 3 V R R R
46 VAR 1 30 V R 46 VAR 1 30 V R
47 DVAR 3 3 V R R R 47 DVAR 3 3 V R R R
48 TEXT 2 2 V V V 48 TEXT 2 2 V V V
49 LINEST 1 2 A R R x 49 LINEST 1 2 A R R x
50 TREND 1 3 A R R R x 50 TREND 1 3 A R R R x
51 LOGEST 1 2 A R R x 51 LOGEST 1 2 A R R x
52 GROWTH 1 3 A R R R x 52 GROWTH 1 3 A R R R x
56 PV 3 5 V V V V V V 56 PV 3 5 V V V V V V
# Built-In Sheet Functions in BIFF2 # Built-In Sheet Functions in BIFF2
57 FV 3 5 V V V V V V 57 FV 3 5 V V V V V V
58 NPER 3 5 V V V V V V 58 NPER 3 5 V V V V V V
59 PMT 3 5 V V V V V V 59 PMT 3 5 V V V V V V
60 RATE 3 6 V V V V V V V 60 RATE 3 6 V V V V V V V
61 MIRR 3 3 V R V V 61 MIRR 3 3 V R V V
62 IRR 1 2 V R V 62 IRR 1 2 V R V
63 RAND 0 0 V - x 63 RAND 0 0 V - x
64 MATCH 2 3 V V R R 64 MATCH 2 3 V V R R
65 DATE 3 3 V V V V 65 DATE 3 3 V V V V
66 TIME 3 3 V V V V 66 TIME 3 3 V V V V
67 DAY 1 1 V V 67 DAY 1 1 V V
68 MONTH 1 1 V V 68 MONTH 1 1 V V
69 YEAR 1 1 V V 69 YEAR 1 1 V V
70 WEEKDAY 1 1 V V x 70 WEEKDAY 1 1 V V x
71 HOUR 1 1 V V 71 HOUR 1 1 V V
72 MINUTE 1 1 V V 72 MINUTE 1 1 V V
73 SECOND 1 1 V V 73 SECOND 1 1 V V
74 NOW 0 0 V - x 74 NOW 0 0 V - x
75 AREAS 1 1 V R 75 AREAS 1 1 V R
76 ROWS 1 1 V R 76 ROWS 1 1 V R
77 COLUMNS 1 1 V R 77 COLUMNS 1 1 V R
78 OFFSET 3 5 R R V V V V x 78 OFFSET 3 5 R R V V V V x
82 SEARCH 2 3 V V V V 82 SEARCH 2 3 V V V V
83 TRANSPOSE 1 1 A A 83 TRANSPOSE 1 1 A A
86 TYPE 1 1 V V 86 TYPE 1 1 V V
97 ATAN2 2 2 V V V 97 ATAN2 2 2 V V V
98 ASIN 1 1 V V 98 ASIN 1 1 V V
99 ACOS 1 1 V V 99 ACOS 1 1 V V
100 CHOOSE 2 30 R V R 100 CHOOSE 2 30 R V R
101 HLOOKUP 3 3 V V R R x 101 HLOOKUP 3 3 V V R R x
102 VLOOKUP 3 3 V V R R x 102 VLOOKUP 3 3 V V R R x
105 ISREF 1 1 V R 105 ISREF 1 1 V R
109 LOG 1 2 V V V 109 LOG 1 2 V V V
111 CHAR 1 1 V V 111 CHAR 1 1 V V
112 LOWER 1 1 V V 112 LOWER 1 1 V V
113 UPPER 1 1 V V 113 UPPER 1 1 V V
114 PROPER 1 1 V V 114 PROPER 1 1 V V
115 LEFT 1 2 V V V 115 LEFT 1 2 V V V
116 RIGHT 1 2 V V V 116 RIGHT 1 2 V V V
117 EXACT 2 2 V V V 117 EXACT 2 2 V V V
118 TRIM 1 1 V V 118 TRIM 1 1 V V
119 REPLACE 4 4 V V V V V 119 REPLACE 4 4 V V V V V
120 SUBSTITUTE 3 4 V V V V V 120 SUBSTITUTE 3 4 V V V V V
121 CODE 1 1 V V 121 CODE 1 1 V V
124 FIND 2 3 V V V V 124 FIND 2 3 V V V V
125 CELL 1 2 V V R x 125 CELL 1 2 V V R x
126 ISERR 1 1 V V 126 ISERR 1 1 V V
127 ISTEXT 1 1 V V 127 ISTEXT 1 1 V V
128 ISNUMBER 1 1 V V 128 ISNUMBER 1 1 V V
129 ISBLANK 1 1 V V 129 ISBLANK 1 1 V V
130 T 1 1 V R 130 T 1 1 V R
131 N 1 1 V R 131 N 1 1 V R
140 DATEVALUE 1 1 V V 140 DATEVALUE 1 1 V V
141 TIMEVALUE 1 1 V V 141 TIMEVALUE 1 1 V V
142 SLN 3 3 V V V V 142 SLN 3 3 V V V V
143 SYD 4 4 V V V V V 143 SYD 4 4 V V V V V
144 DDB 4 5 V V V V V V 144 DDB 4 5 V V V V V V
148 INDIRECT 1 2 R V V x 148 INDIRECT 1 2 R V V x
162 CLEAN 1 1 V V 162 CLEAN 1 1 V V
163 MDETERM 1 1 V A 163 MDETERM 1 1 V A
164 MINVERSE 1 1 A A 164 MINVERSE 1 1 A A
165 MMULT 2 2 A A A 165 MMULT 2 2 A A A
167 IPMT 4 6 V V V V V V V 167 IPMT 4 6 V V V V V V V
168 PPMT 4 6 V V V V V V V 168 PPMT 4 6 V V V V V V V
169 COUNTA 0 30 V R 169 COUNTA 0 30 V R
183 PRODUCT 0 30 V R 183 PRODUCT 0 30 V R
184 FACT 1 1 V V 184 FACT 1 1 V V
189 DPRODUCT 3 3 V R R R 189 DPRODUCT 3 3 V R R R
190 ISNONTEXT 1 1 V V 190 ISNONTEXT 1 1 V V
193 STDEVP 1 30 V R 193 STDEVP 1 30 V R
194 VARP 1 30 V R 194 VARP 1 30 V R
195 DSTDEVP 3 3 V R R R 195 DSTDEVP 3 3 V R R R
196 DVARP 3 3 V R R R 196 DVARP 3 3 V R R R
197 TRUNC 1 1 V V x 197 TRUNC 1 1 V V x
198 ISLOGICAL 1 1 V V 198 ISLOGICAL 1 1 V V
199 DCOUNTA 3 3 V R R R 199 DCOUNTA 3 3 V R R R
# New Built-In Sheet Functions in BIFF3 # New Built-In Sheet Functions in BIFF3
49 LINEST 1 4 A R R V V x 49 LINEST 1 4 A R R V V x
50 TREND 1 4 A R R R V x 50 TREND 1 4 A R R R V x
51 LOGEST 1 4 A R R V V x 51 LOGEST 1 4 A R R V V x
52 GROWTH 1 4 A R R R V x 52 GROWTH 1 4 A R R R V x
197 TRUNC 1 2 V V V x 197 TRUNC 1 2 V V V x
204 YEN 1 2 V V V x 204 YEN 1 2 V V V x
205 FINDB 2 3 V V V V 205 FINDB 2 3 V V V V
206 SEARCHB 2 3 V V V V 206 SEARCHB 2 3 V V V V
207 REPLACEB 4 4 V V V V V 207 REPLACEB 4 4 V V V V V
208 LEFTB 1 2 V V V 208 LEFTB 1 2 V V V
209 RIGHTB 1 2 V V V 209 RIGHTB 1 2 V V V
210 MIDB 3 3 V V V V 210 MIDB 3 3 V V V V
211 LENB 1 1 V V 211 LENB 1 1 V V
212 ROUNDUP 2 2 V V V 212 ROUNDUP 2 2 V V V
213 ROUNDDOWN 2 2 V V V 213 ROUNDDOWN 2 2 V V V
214 ASC 1 1 V V 214 ASC 1 1 V V
215 JIS 1 1 V V x 215 JIS 1 1 V V x
219 ADDRESS 2 5 V V V V V V 219 ADDRESS 2 5 V V V V V V
220 DAYS360 2 2 V V V x 220 DAYS360 2 2 V V V x
221 TODAY 0 0 V - x 221 TODAY 0 0 V - x
222 VDB 5 7 V V V V V V V V 222 VDB 5 7 V V V V V V V V
227 MEDIAN 1 30 V R ... 227 MEDIAN 1 30 V R ...
228 SUMPRODUCT 1 30 V A ... 228 SUMPRODUCT 1 30 V A ...
229 SINH 1 1 V V 229 SINH 1 1 V V
230 COSH 1 1 V V 230 COSH 1 1 V V
231 TANH 1 1 V V 231 TANH 1 1 V V
232 ASINH 1 1 V V 232 ASINH 1 1 V V
233 ACOSH 1 1 V V 233 ACOSH 1 1 V V
234 ATANH 1 1 V V 234 ATANH 1 1 V V
235 DGET 3 3 V R R R 235 DGET 3 3 V R R R
244 INFO 1 1 V V 244 INFO 1 1 V V
# New Built-In Sheet Functions in BIFF4 # New Built-In Sheet Functions in BIFF4
14 FIXED 2 3 V V V V x 14 FIXED 2 3 V V V V x
204 USDOLLAR 1 2 V V V x 204 USDOLLAR 1 2 V V V x
215 DBCS 1 1 V V x 215 DBCS 1 1 V V x
216 RANK 2 3 V V R V 216 RANK 2 3 V V R V
247 DB 4 5 V V V V V V 247 DB 4 5 V V V V V V
252 FREQUENCY 2 2 A R R 252 FREQUENCY 2 2 A R R
261 ERROR.TYPE 1 1 V V 261 ERROR.TYPE 1 1 V V
269 AVEDEV 1 30 V R ... 269 AVEDEV 1 30 V R ...
270 BETADIST 3 5 V V V V V V 270 BETADIST 3 5 V V V V V V
271 GAMMALN 1 1 V V 271 GAMMALN 1 1 V V
272 BETAINV 3 5 V V V V V V 272 BETAINV 3 5 V V V V V V
273 BINOMDIST 4 4 V V V V V 273 BINOMDIST 4 4 V V V V V
274 CHIDIST 2 2 V V V 274 CHIDIST 2 2 V V V
275 CHIINV 2 2 V V V 275 CHIINV 2 2 V V V
276 COMBIN 2 2 V V V 276 COMBIN 2 2 V V V
277 CONFIDENCE 3 3 V V V V 277 CONFIDENCE 3 3 V V V V
278 CRITBINOM 3 3 V V V V 278 CRITBINOM 3 3 V V V V
279 EVEN 1 1 V V 279 EVEN 1 1 V V
280 EXPONDIST 3 3 V V V V 280 EXPONDIST 3 3 V V V V
281 FDIST 3 3 V V V V 281 FDIST 3 3 V V V V
282 FINV 3 3 V V V V 282 FINV 3 3 V V V V
283 FISHER 1 1 V V 283 FISHER 1 1 V V
284 FISHERINV 1 1 V V 284 FISHERINV 1 1 V V
285 FLOOR 2 2 V V V 285 FLOOR 2 2 V V V
286 GAMMADIST 4 4 V V V V V 286 GAMMADIST 4 4 V V V V V
287 GAMMAINV 3 3 V V V V 287 GAMMAINV 3 3 V V V V
288 CEILING 2 2 V V V 288 CEILING 2 2 V V V
289 HYPGEOMDIST 4 4 V V V V V 289 HYPGEOMDIST 4 4 V V V V V
290 LOGNORMDIST 3 3 V V V V 290 LOGNORMDIST 3 3 V V V V
291 LOGINV 3 3 V V V V 291 LOGINV 3 3 V V V V
292 NEGBINOMDIST 3 3 V V V V 292 NEGBINOMDIST 3 3 V V V V
293 NORMDIST 4 4 V V V V V 293 NORMDIST 4 4 V V V V V
294 NORMSDIST 1 1 V V 294 NORMSDIST 1 1 V V
295 NORMINV 3 3 V V V V 295 NORMINV 3 3 V V V V
296 NORMSINV 1 1 V V 296 NORMSINV 1 1 V V
297 STANDARDIZE 3 3 V V V V 297 STANDARDIZE 3 3 V V V V
298 ODD 1 1 V V 298 ODD 1 1 V V
299 PERMUT 2 2 V V V 299 PERMUT 2 2 V V V
300 POISSON 3 3 V V V V 300 POISSON 3 3 V V V V
301 TDIST 3 3 V V V V 301 TDIST 3 3 V V V V
302 WEIBULL 4 4 V V V V V 302 WEIBULL 4 4 V V V V V
303 SUMXMY2 2 2 V A A 303 SUMXMY2 2 2 V A A
304 SUMX2MY2 2 2 V A A 304 SUMX2MY2 2 2 V A A
305 SUMX2PY2 2 2 V A A 305 SUMX2PY2 2 2 V A A
306 CHITEST 2 2 V A A 306 CHITEST 2 2 V A A
307 CORREL 2 2 V A A 307 CORREL 2 2 V A A
308 COVAR 2 2 V A A 308 COVAR 2 2 V A A
309 FORECAST 3 3 V V A A 309 FORECAST 3 3 V V A A
310 FTEST 2 2 V A A 310 FTEST 2 2 V A A
311 INTERCEPT 2 2 V A A 311 INTERCEPT 2 2 V A A
312 PEARSON 2 2 V A A 312 PEARSON 2 2 V A A
313 RSQ 2 2 V A A 313 RSQ 2 2 V A A
314 STEYX 2 2 V A A 314 STEYX 2 2 V A A
315 SLOPE 2 2 V A A 315 SLOPE 2 2 V A A
316 TTEST 4 4 V A A V V 316 TTEST 4 4 V A A V V
317 PROB 3 4 V A A V V 317 PROB 3 4 V A A V V
318 DEVSQ 1 30 V R ... 318 DEVSQ 1 30 V R ...
319 GEOMEAN 1 30 V R ... 319 GEOMEAN 1 30 V R ...
320 HARMEAN 1 30 V R ... 320 HARMEAN 1 30 V R ...
321 SUMSQ 0 30 V R ... 321 SUMSQ 0 30 V R ...
322 KURT 1 30 V R ... 322 KURT 1 30 V R ...
323 SKEW 1 30 V R ... 323 SKEW 1 30 V R ...
324 ZTEST 2 3 V R V V 324 ZTEST 2 3 V R V V
325 LARGE 2 2 V R V 325 LARGE 2 2 V R V
326 SMALL 2 2 V R V 326 SMALL 2 2 V R V
327 QUARTILE 2 2 V R V 327 QUARTILE 2 2 V R V
328 PERCENTILE 2 2 V R V 328 PERCENTILE 2 2 V R V
329 PERCENTRANK 2 3 V R V V 329 PERCENTRANK 2 3 V R V V
330 MODE 1 30 V A 330 MODE 1 30 V A
331 TRIMMEAN 2 2 V R V 331 TRIMMEAN 2 2 V R V
332 TINV 2 2 V V V 332 TINV 2 2 V V V
# New Built-In Sheet Functions in BIFF5 # New Built-In Sheet Functions in BIFF5
70 WEEKDAY 1 2 V V V x 70 WEEKDAY 1 2 V V V x
101 HLOOKUP 3 4 V V R R V x 101 HLOOKUP 3 4 V V R R V x
102 VLOOKUP 3 4 V V R R V x 102 VLOOKUP 3 4 V V R R V x
220 DAYS360 2 3 V V V V x 220 DAYS360 2 3 V V V V x
336 CONCATENATE 0 30 V V 336 CONCATENATE 0 30 V V
337 POWER 2 2 V V V 337 POWER 2 2 V V V
342 RADIANS 1 1 V V 342 RADIANS 1 1 V V
343 DEGREES 1 1 V V 343 DEGREES 1 1 V V
344 SUBTOTAL 2 30 V V R 344 SUBTOTAL 2 30 V V R
345 SUMIF 2 3 V R V R 345 SUMIF 2 3 V R V R
346 COUNTIF 2 2 V R V 346 COUNTIF 2 2 V R V
347 COUNTBLANK 1 1 V R 347 COUNTBLANK 1 1 V R
350 ISPMT 4 4 V V V V V 350 ISPMT 4 4 V V V V V
351 DATEDIF 3 3 V V V V 351 DATEDIF 3 3 V V V V
352 DATESTRING 1 1 V V 352 DATESTRING 1 1 V V
353 NUMBERSTRING 2 2 V V V 353 NUMBERSTRING 2 2 V V V
354 ROMAN 1 2 V V V 354 ROMAN 1 2 V V V
# New Built-In Sheet Functions in BIFF8 # New Built-In Sheet Functions in BIFF8
358 GETPIVOTDATA 2 30 358 GETPIVOTDATA 2 30
359 HYPERLINK 1 2 V V V 359 HYPERLINK 1 2 V V V
360 PHONETIC 1 1 V R 360 PHONETIC 1 1 V R
361 AVERAGEA 1 30 V R ... 361 AVERAGEA 1 30 V R ...
362 MAXA 1 30 V R ... 362 MAXA 1 30 V R ...
363 MINA 1 30 V R ... 363 MINA 1 30 V R ...
364 STDEVPA 1 30 V R ... 364 STDEVPA 1 30 V R ...
365 VARPA 1 30 V R ... 365 VARPA 1 30 V R ...
366 STDEVA 1 30 V R ... 366 STDEVA 1 30 V R ...
367 VARA 1 30 V R ... 367 VARA 1 30 V R ...

View File

@ -1,286 +1,286 @@
# Licensed to the Apache Software Foundation (ASF) under one or more # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with # contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. # this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0 # The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with # (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at # the License. You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# Created by (org.apache.poi.hssf.record.formula.function.ExcelFileFormatDocFunctionExtractor) # Created by (org.apache.poi.hssf.record.formula.function.ExcelFileFormatDocFunctionExtractor)
# from source file 'excelfileformat.odt' (size=356107, md5=0x8f789cb6e75594caf068f8e193004ef4) # from source file 'excelfileformat.odt' (size=356107, md5=0x8f789cb6e75594caf068f8e193004ef4)
# ! + some manual edits ! # ! + some manual edits !
# #
#Columns: (index, name, minParams, maxParams, returnClass, paramClasses, isVolatile, hasFootnote ) #Columns: (index, name, minParams, maxParams, returnClass, paramClasses, isVolatile, hasFootnote )
# Built-In Sheet Functions in BIFF2 # Built-In Sheet Functions in BIFF2
0 COUNT 0 30 V R 0 COUNT 0 30 V R
1 IF 2 3 R V R R 1 IF 2 3 R V R R
2 ISNA 1 1 V V 2 ISNA 1 1 V V
3 ISERROR 1 1 V V 3 ISERROR 1 1 V V
4 SUM 0 30 V R 4 SUM 0 30 V R
5 AVERAGE 1 30 V R 5 AVERAGE 1 30 V R
6 MIN 1 30 V R 6 MIN 1 30 V R
7 MAX 1 30 V R 7 MAX 1 30 V R
8 ROW 0 1 V R 8 ROW 0 1 V R
9 COLUMN 0 1 V R 9 COLUMN 0 1 V R
10 NA 0 0 V - 10 NA 0 0 V -
11 NPV 2 30 V V R 11 NPV 2 30 V V R
12 STDEV 1 30 V R 12 STDEV 1 30 V R
13 DOLLAR 1 2 V V V 13 DOLLAR 1 2 V V V
14 FIXED 2 2 V V V x 14 FIXED 2 2 V V V x
15 SIN 1 1 V V 15 SIN 1 1 V V
16 COS 1 1 V V 16 COS 1 1 V V
17 TAN 1 1 V V 17 TAN 1 1 V V
18 ATAN 1 1 V V 18 ATAN 1 1 V V
19 PI 0 0 V - 19 PI 0 0 V -
20 SQRT 1 1 V V 20 SQRT 1 1 V V
21 EXP 1 1 V V 21 EXP 1 1 V V
22 LN 1 1 V V 22 LN 1 1 V V
23 LOG10 1 1 V V 23 LOG10 1 1 V V
24 ABS 1 1 V V 24 ABS 1 1 V V
25 INT 1 1 V V 25 INT 1 1 V V
26 SIGN 1 1 V V 26 SIGN 1 1 V V
27 ROUND 2 2 V V V 27 ROUND 2 2 V V V
28 LOOKUP 2 3 V V R R 28 LOOKUP 2 3 V V R R
29 INDEX 2 4 R R V V V 29 INDEX 2 4 R R V V V
30 REPT 2 2 V V V 30 REPT 2 2 V V V
31 MID 3 3 V V V V 31 MID 3 3 V V V V
32 LEN 1 1 V V 32 LEN 1 1 V V
33 VALUE 1 1 V V 33 VALUE 1 1 V V
34 TRUE 0 0 V - 34 TRUE 0 0 V -
35 FALSE 0 0 V - 35 FALSE 0 0 V -
36 AND 1 30 V R 36 AND 1 30 V R
37 OR 1 30 V R 37 OR 1 30 V R
38 NOT 1 1 V V 38 NOT 1 1 V V
39 MOD 2 2 V V V 39 MOD 2 2 V V V
40 DCOUNT 3 3 V R R R 40 DCOUNT 3 3 V R R R
41 DSUM 3 3 V R R R 41 DSUM 3 3 V R R R
42 DAVERAGE 3 3 V R R R 42 DAVERAGE 3 3 V R R R
43 DMIN 3 3 V R R R 43 DMIN 3 3 V R R R
44 DMAX 3 3 V R R R 44 DMAX 3 3 V R R R
45 DSTDEV 3 3 V R R R 45 DSTDEV 3 3 V R R R
46 VAR 1 30 V R 46 VAR 1 30 V R
47 DVAR 3 3 V R R R 47 DVAR 3 3 V R R R
48 TEXT 2 2 V V V 48 TEXT 2 2 V V V
49 LINEST 1 2 A R R x 49 LINEST 1 2 A R R x
50 TREND 1 3 A R R R x 50 TREND 1 3 A R R R x
51 LOGEST 1 2 A R R x 51 LOGEST 1 2 A R R x
52 GROWTH 1 3 A R R R x 52 GROWTH 1 3 A R R R x
56 PV 3 5 V V V V V V 56 PV 3 5 V V V V V V
# Built-In Sheet Functions in BIFF2 # Built-In Sheet Functions in BIFF2
57 FV 3 5 V V V V V V 57 FV 3 5 V V V V V V
58 NPER 3 5 V V V V V V 58 NPER 3 5 V V V V V V
59 PMT 3 5 V V V V V V 59 PMT 3 5 V V V V V V
60 RATE 3 6 V V V V V V V 60 RATE 3 6 V V V V V V V
61 MIRR 3 3 V A V V 61 MIRR 3 3 V A V V
62 IRR 1 2 V A V 62 IRR 1 2 V A V
63 RAND 0 0 V - x 63 RAND 0 0 V - x
64 MATCH 2 3 V V R R 64 MATCH 2 3 V V R R
65 DATE 3 3 V V V V 65 DATE 3 3 V V V V
66 TIME 3 3 V V V V 66 TIME 3 3 V V V V
67 DAY 1 1 V V 67 DAY 1 1 V V
68 MONTH 1 1 V V 68 MONTH 1 1 V V
69 YEAR 1 1 V V 69 YEAR 1 1 V V
70 WEEKDAY 1 1 V V x 70 WEEKDAY 1 1 V V x
71 HOUR 1 1 V V 71 HOUR 1 1 V V
72 MINUTE 1 1 V V 72 MINUTE 1 1 V V
73 SECOND 1 1 V V 73 SECOND 1 1 V V
74 NOW 0 0 V - x 74 NOW 0 0 V - x
75 AREAS 1 1 V R 75 AREAS 1 1 V R
76 ROWS 1 1 V A 76 ROWS 1 1 V A
77 COLUMNS 1 1 V A 77 COLUMNS 1 1 V A
78 OFFSET 3 5 R R V V V V x 78 OFFSET 3 5 R R V V V V x
82 SEARCH 2 3 V V V V 82 SEARCH 2 3 V V V V
83 TRANSPOSE 1 1 A A 83 TRANSPOSE 1 1 A A
86 TYPE 1 1 V V 86 TYPE 1 1 V V
97 ATAN2 2 2 V V V 97 ATAN2 2 2 V V V
98 ASIN 1 1 V V 98 ASIN 1 1 V V
99 ACOS 1 1 V V 99 ACOS 1 1 V V
100 CHOOSE 2 30 R V R 100 CHOOSE 2 30 R V R
101 HLOOKUP 3 3 V V R R x 101 HLOOKUP 3 3 V V R R x
102 VLOOKUP 3 3 V V R R x 102 VLOOKUP 3 3 V V R R x
105 ISREF 1 1 V R 105 ISREF 1 1 V R
109 LOG 1 2 V V V 109 LOG 1 2 V V V
111 CHAR 1 1 V V 111 CHAR 1 1 V V
112 LOWER 1 1 V V 112 LOWER 1 1 V V
113 UPPER 1 1 V V 113 UPPER 1 1 V V
114 PROPER 1 1 V V 114 PROPER 1 1 V V
115 LEFT 1 2 V V V 115 LEFT 1 2 V V V
116 RIGHT 1 2 V V V 116 RIGHT 1 2 V V V
117 EXACT 2 2 V V V 117 EXACT 2 2 V V V
118 TRIM 1 1 V V 118 TRIM 1 1 V V
119 REPLACE 4 4 V V V V V 119 REPLACE 4 4 V V V V V
120 SUBSTITUTE 3 4 V V V V V 120 SUBSTITUTE 3 4 V V V V V
121 CODE 1 1 V V 121 CODE 1 1 V V
124 FIND 2 3 V V V V 124 FIND 2 3 V V V V
125 CELL 1 2 V V R x 125 CELL 1 2 V V R x
126 ISERR 1 1 V V 126 ISERR 1 1 V V
127 ISTEXT 1 1 V V 127 ISTEXT 1 1 V V
128 ISNUMBER 1 1 V V 128 ISNUMBER 1 1 V V
129 ISBLANK 1 1 V V 129 ISBLANK 1 1 V V
130 T 1 1 V R 130 T 1 1 V R
131 N 1 1 V R 131 N 1 1 V R
140 DATEVALUE 1 1 V V 140 DATEVALUE 1 1 V V
141 TIMEVALUE 1 1 V V 141 TIMEVALUE 1 1 V V
142 SLN 3 3 V V V V 142 SLN 3 3 V V V V
143 SYD 4 4 V V V V V 143 SYD 4 4 V V V V V
144 DDB 4 5 V V V V V V 144 DDB 4 5 V V V V V V
148 INDIRECT 1 2 R V V x 148 INDIRECT 1 2 R V V x
162 CLEAN 1 1 V V 162 CLEAN 1 1 V V
163 MDETERM 1 1 V A 163 MDETERM 1 1 V A
164 MINVERSE 1 1 A A 164 MINVERSE 1 1 A A
165 MMULT 2 2 A A A 165 MMULT 2 2 A A A
167 IPMT 4 6 V V V V V V V 167 IPMT 4 6 V V V V V V V
168 PPMT 4 6 V V V V V V V 168 PPMT 4 6 V V V V V V V
169 COUNTA 0 30 V R 169 COUNTA 0 30 V R
183 PRODUCT 0 30 V R 183 PRODUCT 0 30 V R
184 FACT 1 1 V V 184 FACT 1 1 V V
189 DPRODUCT 3 3 V R R R 189 DPRODUCT 3 3 V R R R
190 ISNONTEXT 1 1 V V 190 ISNONTEXT 1 1 V V
193 STDEVP 1 30 V R 193 STDEVP 1 30 V R
194 VARP 1 30 V R 194 VARP 1 30 V R
195 DSTDEVP 3 3 V R R R 195 DSTDEVP 3 3 V R R R
196 DVARP 3 3 V R R R 196 DVARP 3 3 V R R R
197 TRUNC 1 1 V V x 197 TRUNC 1 1 V V x
198 ISLOGICAL 1 1 V V 198 ISLOGICAL 1 1 V V
199 DCOUNTA 3 3 V R R R 199 DCOUNTA 3 3 V R R R
# New Built-In Sheet Functions in BIFF3 # New Built-In Sheet Functions in BIFF3
49 LINEST 1 4 A R R V V x 49 LINEST 1 4 A R R V V x
50 TREND 1 4 A R R R V x 50 TREND 1 4 A R R R V x
51 LOGEST 1 4 A R R V V x 51 LOGEST 1 4 A R R V V x
52 GROWTH 1 4 A R R R V x 52 GROWTH 1 4 A R R R V x
197 TRUNC 1 2 V V V x 197 TRUNC 1 2 V V V x
204 YEN 1 2 V V V x 204 YEN 1 2 V V V x
205 FINDB 2 3 V V V V 205 FINDB 2 3 V V V V
206 SEARCHB 2 3 V V V V 206 SEARCHB 2 3 V V V V
207 REPLACEB 4 4 V V V V V 207 REPLACEB 4 4 V V V V V
208 LEFTB 1 2 V V V 208 LEFTB 1 2 V V V
209 RIGHTB 1 2 V V V 209 RIGHTB 1 2 V V V
210 MIDB 3 3 V V V V 210 MIDB 3 3 V V V V
211 LENB 1 1 V V 211 LENB 1 1 V V
212 ROUNDUP 2 2 V V V 212 ROUNDUP 2 2 V V V
213 ROUNDDOWN 2 2 V V V 213 ROUNDDOWN 2 2 V V V
214 ASC 1 1 V V 214 ASC 1 1 V V
215 JIS 1 1 V V x 215 JIS 1 1 V V x
219 ADDRESS 2 5 V V V V V V 219 ADDRESS 2 5 V V V V V V
220 DAYS360 2 2 V V V x 220 DAYS360 2 2 V V V x
221 TODAY 0 0 V - x 221 TODAY 0 0 V - x
222 VDB 5 7 V V V V V V V V 222 VDB 5 7 V V V V V V V V
227 MEDIAN 1 30 V R ... 227 MEDIAN 1 30 V R ...
228 SUMPRODUCT 1 30 V A ... 228 SUMPRODUCT 1 30 V A ...
229 SINH 1 1 V V 229 SINH 1 1 V V
230 COSH 1 1 V V 230 COSH 1 1 V V
231 TANH 1 1 V V 231 TANH 1 1 V V
232 ASINH 1 1 V V 232 ASINH 1 1 V V
233 ACOSH 1 1 V V 233 ACOSH 1 1 V V
234 ATANH 1 1 V V 234 ATANH 1 1 V V
235 DGET 3 3 V R R R 235 DGET 3 3 V R R R
244 INFO 1 1 V V 244 INFO 1 1 V V
# New Built-In Sheet Functions in BIFF4 # New Built-In Sheet Functions in BIFF4
14 FIXED 2 3 V V V V x 14 FIXED 2 3 V V V V x
204 USDOLLAR 1 2 V V V x 204 USDOLLAR 1 2 V V V x
215 DBCS 1 1 V V x 215 DBCS 1 1 V V x
216 RANK 2 3 V V R V 216 RANK 2 3 V V R V
247 DB 4 5 V V V V V V 247 DB 4 5 V V V V V V
252 FREQUENCY 2 2 A R R 252 FREQUENCY 2 2 A R R
261 ERROR.TYPE 1 1 V V 261 ERROR.TYPE 1 1 V V
269 AVEDEV 1 30 V R ... 269 AVEDEV 1 30 V R ...
270 BETADIST 3 5 V V V V V V 270 BETADIST 3 5 V V V V V V
271 GAMMALN 1 1 V V 271 GAMMALN 1 1 V V
272 BETAINV 3 5 V V V V V V 272 BETAINV 3 5 V V V V V V
273 BINOMDIST 4 4 V V V V V 273 BINOMDIST 4 4 V V V V V
274 CHIDIST 2 2 V V V 274 CHIDIST 2 2 V V V
275 CHIINV 2 2 V V V 275 CHIINV 2 2 V V V
276 COMBIN 2 2 V V V 276 COMBIN 2 2 V V V
277 CONFIDENCE 3 3 V V V V 277 CONFIDENCE 3 3 V V V V
278 CRITBINOM 3 3 V V V V 278 CRITBINOM 3 3 V V V V
279 EVEN 1 1 V V 279 EVEN 1 1 V V
280 EXPONDIST 3 3 V V V V 280 EXPONDIST 3 3 V V V V
281 FDIST 3 3 V V V V 281 FDIST 3 3 V V V V
282 FINV 3 3 V V V V 282 FINV 3 3 V V V V
283 FISHER 1 1 V V 283 FISHER 1 1 V V
284 FISHERINV 1 1 V V 284 FISHERINV 1 1 V V
285 FLOOR 2 2 V V V 285 FLOOR 2 2 V V V
286 GAMMADIST 4 4 V V V V V 286 GAMMADIST 4 4 V V V V V
287 GAMMAINV 3 3 V V V V 287 GAMMAINV 3 3 V V V V
288 CEILING 2 2 V V V 288 CEILING 2 2 V V V
289 HYPGEOMDIST 4 4 V V V V V 289 HYPGEOMDIST 4 4 V V V V V
290 LOGNORMDIST 3 3 V V V V 290 LOGNORMDIST 3 3 V V V V
291 LOGINV 3 3 V V V V 291 LOGINV 3 3 V V V V
292 NEGBINOMDIST 3 3 V V V V 292 NEGBINOMDIST 3 3 V V V V
293 NORMDIST 4 4 V V V V V 293 NORMDIST 4 4 V V V V V
294 NORMSDIST 1 1 V V 294 NORMSDIST 1 1 V V
295 NORMINV 3 3 V V V V 295 NORMINV 3 3 V V V V
296 NORMSINV 1 1 V V 296 NORMSINV 1 1 V V
297 STANDARDIZE 3 3 V V V V 297 STANDARDIZE 3 3 V V V V
298 ODD 1 1 V V 298 ODD 1 1 V V
299 PERMUT 2 2 V V V 299 PERMUT 2 2 V V V
300 POISSON 3 3 V V V V 300 POISSON 3 3 V V V V
301 TDIST 3 3 V V V V 301 TDIST 3 3 V V V V
302 WEIBULL 4 4 V V V V V 302 WEIBULL 4 4 V V V V V
303 SUMXMY2 2 2 V A A 303 SUMXMY2 2 2 V A A
304 SUMX2MY2 2 2 V A A 304 SUMX2MY2 2 2 V A A
305 SUMX2PY2 2 2 V A A 305 SUMX2PY2 2 2 V A A
306 CHITEST 2 2 V A A 306 CHITEST 2 2 V A A
307 CORREL 2 2 V A A 307 CORREL 2 2 V A A
308 COVAR 2 2 V A A 308 COVAR 2 2 V A A
309 FORECAST 3 3 V V A A 309 FORECAST 3 3 V V A A
310 FTEST 2 2 V A A 310 FTEST 2 2 V A A
311 INTERCEPT 2 2 V A A 311 INTERCEPT 2 2 V A A
312 PEARSON 2 2 V A A 312 PEARSON 2 2 V A A
313 RSQ 2 2 V A A 313 RSQ 2 2 V A A
314 STEYX 2 2 V A A 314 STEYX 2 2 V A A
315 SLOPE 2 2 V A A 315 SLOPE 2 2 V A A
316 TTEST 4 4 V A A V V 316 TTEST 4 4 V A A V V
317 PROB 3 4 V A A V V 317 PROB 3 4 V A A V V
318 DEVSQ 1 30 V R ... 318 DEVSQ 1 30 V R ...
319 GEOMEAN 1 30 V R ... 319 GEOMEAN 1 30 V R ...
320 HARMEAN 1 30 V R ... 320 HARMEAN 1 30 V R ...
321 SUMSQ 0 30 V R ... 321 SUMSQ 0 30 V R ...
322 KURT 1 30 V R ... 322 KURT 1 30 V R ...
323 SKEW 1 30 V R ... 323 SKEW 1 30 V R ...
324 ZTEST 2 3 V R V V 324 ZTEST 2 3 V R V V
325 LARGE 2 2 V R V 325 LARGE 2 2 V R V
326 SMALL 2 2 V R V 326 SMALL 2 2 V R V
327 QUARTILE 2 2 V R V 327 QUARTILE 2 2 V R V
328 PERCENTILE 2 2 V R V 328 PERCENTILE 2 2 V R V
329 PERCENTRANK 2 3 V R V V 329 PERCENTRANK 2 3 V R V V
330 MODE 1 30 V A 330 MODE 1 30 V A
331 TRIMMEAN 2 2 V R V 331 TRIMMEAN 2 2 V R V
332 TINV 2 2 V V V 332 TINV 2 2 V V V
# New Built-In Sheet Functions in BIFF5 # New Built-In Sheet Functions in BIFF5
70 WEEKDAY 1 2 V V V x 70 WEEKDAY 1 2 V V V x
101 HLOOKUP 3 4 V V R R V x 101 HLOOKUP 3 4 V V R R V x
102 VLOOKUP 3 4 V V R R V x 102 VLOOKUP 3 4 V V R R V x
220 DAYS360 2 3 V V V V x 220 DAYS360 2 3 V V V V x
336 CONCATENATE 0 30 V V 336 CONCATENATE 0 30 V V
337 POWER 2 2 V V V 337 POWER 2 2 V V V
342 RADIANS 1 1 V V 342 RADIANS 1 1 V V
343 DEGREES 1 1 V V 343 DEGREES 1 1 V V
344 SUBTOTAL 2 30 V V R 344 SUBTOTAL 2 30 V V R
345 SUMIF 2 3 V R V R 345 SUMIF 2 3 V R V R
346 COUNTIF 2 2 V R V 346 COUNTIF 2 2 V R V
347 COUNTBLANK 1 1 V R 347 COUNTBLANK 1 1 V R
350 ISPMT 4 4 V V V V V 350 ISPMT 4 4 V V V V V
351 DATEDIF 3 3 V V V V 351 DATEDIF 3 3 V V V V
352 DATESTRING 1 1 V V 352 DATESTRING 1 1 V V
353 NUMBERSTRING 2 2 V V V 353 NUMBERSTRING 2 2 V V V
354 ROMAN 1 2 V V V 354 ROMAN 1 2 V V V
# New Built-In Sheet Functions in BIFF8 # New Built-In Sheet Functions in BIFF8
358 GETPIVOTDATA 2 30 358 GETPIVOTDATA 2 30
359 HYPERLINK 1 2 V V V 359 HYPERLINK 1 2 V V V
360 PHONETIC 1 1 V R 360 PHONETIC 1 1 V R
361 AVERAGEA 1 30 V R ... 361 AVERAGEA 1 30 V R ...
362 MAXA 1 30 V R ... 362 MAXA 1 30 V R ...
363 MINA 1 30 V R ... 363 MINA 1 30 V R ...
364 STDEVPA 1 30 V R ... 364 STDEVPA 1 30 V R ...
365 VARPA 1 30 V R ... 365 VARPA 1 30 V R ...
366 STDEVA 1 30 V R ... 366 STDEVA 1 30 V R ...
367 VARA 1 30 V R ... 367 VARA 1 30 V R ...

File diff suppressed because it is too large Load Diff