Lines 1679-1691
Link Here
|
1679 |
* '0' looks to be a good choice. |
1679 |
* '0' looks to be a good choice. |
1680 |
*/ |
1680 |
*/ |
1681 |
char defaultChar = '0'; |
1681 |
char defaultChar = '0'; |
1682 |
|
1682 |
|
1683 |
/** |
1683 |
/** |
1684 |
* This is the multiple that the font height is scaled by when determining the |
1684 |
* This is the multiple that the font height is scaled by when determining the |
1685 |
* boundary of rotated text. |
1685 |
* boundary of rotated text. |
1686 |
*/ |
1686 |
*/ |
1687 |
double fontHeightMultiple = 2.0; |
1687 |
double fontHeightMultiple = 2.0; |
1688 |
|
1688 |
|
1689 |
FontRenderContext frc = new FontRenderContext(null, true, true); |
1689 |
FontRenderContext frc = new FontRenderContext(null, true, true); |
1690 |
|
1690 |
|
1691 |
HSSFWorkbook wb = new HSSFWorkbook(book); |
1691 |
HSSFWorkbook wb = new HSSFWorkbook(book); |
Lines 1701-1713
Link Here
|
1701 |
HSSFRow row = (HSSFRow) it.next(); |
1701 |
HSSFRow row = (HSSFRow) it.next(); |
1702 |
HSSFCell cell = row.getCell(column); |
1702 |
HSSFCell cell = row.getCell(column); |
1703 |
|
1703 |
|
1704 |
boolean isCellInMergedRegion = false; |
1704 |
if (cell == null) continue; |
1705 |
for (int i = 0 ; i < getNumMergedRegions() && ! isCellInMergedRegion; i++) { |
1705 |
|
1706 |
isCellInMergedRegion = getMergedRegionAt(i).contains(row.getRowNum(), column); |
1706 |
int colspan = 1; |
|
|
1707 |
for (int i = 0 ; i < getNumMergedRegions(); i++) { |
1708 |
if (getMergedRegionAt(i).contains(row.getRowNum(), column)) { |
1709 |
cell = row.getCell(getMergedRegionAt(i).getColumnFrom()); |
1710 |
colspan = 1+ getMergedRegionAt(i).getColumnTo() - getMergedRegionAt(i).getColumnFrom(); |
1711 |
} |
1707 |
} |
1712 |
} |
1708 |
|
1713 |
|
1709 |
if (cell == null | isCellInMergedRegion) continue; |
|
|
1710 |
|
1711 |
HSSFCellStyle style = cell.getCellStyle(); |
1714 |
HSSFCellStyle style = cell.getCellStyle(); |
1712 |
HSSFFont font = wb.getFontAt(style.getFontIndex()); |
1715 |
HSSFFont font = wb.getFontAt(style.getFontIndex()); |
1713 |
|
1716 |
|
Lines 1742-1750
Link Here
|
1742 |
trans.concatenate( |
1745 |
trans.concatenate( |
1743 |
AffineTransform.getScaleInstance(1, fontHeightMultiple) |
1746 |
AffineTransform.getScaleInstance(1, fontHeightMultiple) |
1744 |
); |
1747 |
); |
1745 |
width = Math.max(width, layout.getOutline(trans).getBounds().getWidth() / defaultCharWidth); |
1748 |
width = Math.max(width, ((layout.getOutline(trans).getBounds().getWidth() / colspan) / defaultCharWidth) + cell.getCellStyle().getIndention()); |
1746 |
} else { |
1749 |
} else { |
1747 |
width = Math.max(width, layout.getBounds().getWidth() / defaultCharWidth); |
1750 |
width = Math.max(width, ((layout.getBounds().getWidth() / colspan) / defaultCharWidth) + cell.getCellStyle().getIndention()); |
1748 |
} |
1751 |
} |
1749 |
} |
1752 |
} |
1750 |
} else { |
1753 |
} else { |
Lines 1787-1805
Link Here
|
1787 |
trans.concatenate( |
1790 |
trans.concatenate( |
1788 |
AffineTransform.getScaleInstance(1, fontHeightMultiple) |
1791 |
AffineTransform.getScaleInstance(1, fontHeightMultiple) |
1789 |
); |
1792 |
); |
1790 |
width = Math.max(width, layout.getOutline(trans).getBounds().getWidth() / defaultCharWidth); |
1793 |
width = Math.max(width, ((layout.getOutline(trans).getBounds().getWidth() / colspan) / defaultCharWidth) + cell.getCellStyle().getIndention()); |
1791 |
} else { |
1794 |
} else { |
1792 |
width = Math.max(width, layout.getBounds().getWidth() / defaultCharWidth); |
1795 |
width = Math.max(width, ((layout.getBounds().getWidth() / colspan) / defaultCharWidth) + cell.getCellStyle().getIndention()); |
1793 |
} |
1796 |
} |
1794 |
} |
1797 |
} |
1795 |
} |
1798 |
} |
1796 |
|
1799 |
|
1797 |
if (width != -1) { |
1800 |
} |
1798 |
if (width > Short.MAX_VALUE) { //width can be bigger that Short.MAX_VALUE! |
1801 |
if (width != -1) { |
1799 |
width = Short.MAX_VALUE; |
1802 |
if (width > Short.MAX_VALUE) { //width can be bigger that Short.MAX_VALUE! |
1800 |
} |
1803 |
width = Short.MAX_VALUE; |
1801 |
sheet.setColumnWidth(column, (short) (width * 256)); |
|
|
1802 |
} |
1804 |
} |
|
|
1805 |
sheet.setColumnWidth(column, (short) (width * 256)); |
1803 |
} |
1806 |
} |
1804 |
} |
1807 |
} |
1805 |
|
1808 |
|