Source Code Cross Referenced for HSSFRegionUtil.java in  » Collaboration » poi-3.0.2-beta2 » org » apache » poi » hssf » usermodel » contrib » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Collaboration » poi 3.0.2 beta2 » org.apache.poi.hssf.usermodel.contrib 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ====================================================================
002:         Licensed to the Apache Software Foundation (ASF) under one or more
003:         contributor license agreements.  See the NOTICE file distributed with
004:         this work for additional information regarding copyright ownership.
005:         The ASF licenses this file to You under the Apache License, Version 2.0
006:         (the "License"); you may not use this file except in compliance with
007:         the License.  You may obtain a copy of the License at
008:
009:         http://www.apache.org/licenses/LICENSE-2.0
010:
011:         Unless required by applicable law or agreed to in writing, software
012:         distributed under the License is distributed on an "AS IS" BASIS,
013:         WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         See the License for the specific language governing permissions and
015:         limitations under the License.
016:         ==================================================================== */
017:
018:        package org.apache.poi.hssf.usermodel.contrib;
019:
020:        import org.apache.poi.hssf.usermodel.HSSFCell;
021:        import org.apache.poi.hssf.usermodel.HSSFRow;
022:        import org.apache.poi.hssf.usermodel.HSSFSheet;
023:        import org.apache.poi.hssf.usermodel.HSSFWorkbook;
024:
025:        import org.apache.poi.hssf.util.Region;
026:
027:        import org.apache.commons.lang.exception.NestableException;
028:
029:        /**
030:         *  Various utility functions that make working with a region of cells easier.
031:         *
032:         *@author     Eric Pugh epugh@upstate.com
033:         *@since      July 29, 2002
034:         */
035:
036:        public class HSSFRegionUtil {
037:
038:            /**  Constructor for the HSSFRegionUtil object */
039:            private HSSFRegionUtil() {
040:            }
041:
042:            /**
043:             *  Sets the left border for a region of cells by manipulating the cell style
044:             *  of the indidual cells on the left
045:             *
046:             *@param  border                 The new border
047:             *@param  region                 The region that should have the border
048:             *@param  workbook               The workbook that the region is on.
049:             *@param  sheet                  The sheet that the region is on.
050:             *@exception  NestableException  Thrown if the CellStyle can't be changed
051:             */
052:            public static void setBorderLeft(short border, Region region,
053:                    HSSFSheet sheet, HSSFWorkbook workbook)
054:                    throws NestableException {
055:                int rowStart = region.getRowFrom();
056:                int rowEnd = region.getRowTo();
057:                int column = region.getColumnFrom();
058:
059:                for (int i = rowStart; i <= rowEnd; i++) {
060:                    HSSFRow row = HSSFCellUtil.getRow(i, sheet);
061:                    HSSFCell cell = HSSFCellUtil.getCell(row, column);
062:                    HSSFCellUtil.setCellStyleProperty(cell, workbook,
063:                            "borderLeft", new Short(border));
064:                }
065:            }
066:
067:            /**
068:             *  Sets the leftBorderColor attribute of the HSSFRegionUtil object
069:             *
070:             *@param  color                  The color of the border
071:             *@param  region                 The region that should have the border
072:             *@param  workbook               The workbook that the region is on.
073:             *@param  sheet                  The sheet that the region is on.
074:             *@exception  NestableException  Thrown if the CellStyle can't be changed
075:             *      properly.
076:             */
077:            public static void setLeftBorderColor(short color, Region region,
078:                    HSSFSheet sheet, HSSFWorkbook workbook)
079:                    throws NestableException {
080:                int rowStart = region.getRowFrom();
081:                int rowEnd = region.getRowTo();
082:                int column = region.getColumnFrom();
083:
084:                for (int i = rowStart; i <= rowEnd; i++) {
085:                    HSSFRow row = HSSFCellUtil.getRow(i, sheet);
086:                    HSSFCell cell = HSSFCellUtil.getCell(row, column);
087:                    HSSFCellUtil.setCellStyleProperty(cell, workbook,
088:                            "leftBorderColor", new Short(color));
089:                }
090:            }
091:
092:            /**
093:             *  Sets the borderRight attribute of the HSSFRegionUtil object
094:             *
095:             *@param  border                 The new border
096:             *@param  region                 The region that should have the border
097:             *@param  workbook               The workbook that the region is on.
098:             *@param  sheet                  The sheet that the region is on.
099:             *@exception  NestableException  Thrown if the CellStyle can't be changed
100:             */
101:            public static void setBorderRight(short border, Region region,
102:                    HSSFSheet sheet, HSSFWorkbook workbook)
103:                    throws NestableException {
104:                int rowStart = region.getRowFrom();
105:                int rowEnd = region.getRowTo();
106:                int column = region.getColumnTo();
107:
108:                for (int i = rowStart; i <= rowEnd; i++) {
109:                    HSSFRow row = HSSFCellUtil.getRow(i, sheet);
110:                    HSSFCell cell = HSSFCellUtil.getCell(row, column);
111:
112:                    HSSFCellUtil.setCellStyleProperty(cell, workbook,
113:                            "borderRight", new Short(border));
114:                }
115:            }
116:
117:            /**
118:             *  Sets the rightBorderColor attribute of the HSSFRegionUtil object
119:             *
120:             *@param  color                  The color of the border
121:             *@param  region                 The region that should have the border
122:             *@param  workbook               The workbook that the region is on.
123:             *@param  sheet                  The sheet that the region is on.
124:             *@exception  NestableException  Thrown if the CellStyle can't be changed
125:             *      properly.
126:             */
127:            public static void setRightBorderColor(short color, Region region,
128:                    HSSFSheet sheet, HSSFWorkbook workbook)
129:                    throws NestableException {
130:                int rowStart = region.getRowFrom();
131:                int rowEnd = region.getRowTo();
132:                int column = region.getColumnTo();
133:
134:                for (int i = rowStart; i <= rowEnd; i++) {
135:                    HSSFRow row = HSSFCellUtil.getRow(i, sheet);
136:                    HSSFCell cell = HSSFCellUtil.getCell(row, column);
137:                    HSSFCellUtil.setCellStyleProperty(cell, workbook,
138:                            "rightBorderColor", new Short(color));
139:                }
140:            }
141:
142:            /**
143:             *  Sets the borderBottom attribute of the HSSFRegionUtil object
144:             *
145:             *@param  border                 The new border
146:             *@param  region                 The region that should have the border
147:             *@param  workbook               The workbook that the region is on.
148:             *@param  sheet                  The sheet that the region is on.
149:             *@exception  NestableException  Thrown if the CellStyle can't be changed
150:             */
151:            public static void setBorderBottom(short border, Region region,
152:                    HSSFSheet sheet, HSSFWorkbook workbook)
153:                    throws NestableException {
154:                int colStart = region.getColumnFrom();
155:                int colEnd = region.getColumnTo();
156:                int rowIndex = region.getRowTo();
157:                HSSFRow row = HSSFCellUtil.getRow(rowIndex, sheet);
158:                for (int i = colStart; i <= colEnd; i++) {
159:
160:                    HSSFCell cell = HSSFCellUtil.getCell(row, i);
161:                    HSSFCellUtil.setCellStyleProperty(cell, workbook,
162:                            "borderBottom", new Short(border));
163:                }
164:            }
165:
166:            /**
167:             *  Sets the bottomBorderColor attribute of the HSSFRegionUtil object
168:             *
169:             *@param  color                  The color of the border
170:             *@param  region                 The region that should have the border
171:             *@param  workbook               The workbook that the region is on.
172:             *@param  sheet                  The sheet that the region is on.
173:             *@exception  NestableException  Thrown if the CellStyle can't be changed
174:             *      properly.
175:             */
176:            public static void setBottomBorderColor(short color, Region region,
177:                    HSSFSheet sheet, HSSFWorkbook workbook)
178:                    throws NestableException {
179:                int colStart = region.getColumnFrom();
180:                int colEnd = region.getColumnTo();
181:                int rowIndex = region.getRowTo();
182:                HSSFRow row = HSSFCellUtil.getRow(rowIndex, sheet);
183:                for (int i = colStart; i <= colEnd; i++) {
184:                    HSSFCell cell = HSSFCellUtil.getCell(row, i);
185:                    HSSFCellUtil.setCellStyleProperty(cell, workbook,
186:                            "bottomBorderColor", new Short(color));
187:                }
188:            }
189:
190:            /**
191:             *  Sets the borderBottom attribute of the HSSFRegionUtil object
192:             *
193:             *@param  border                 The new border
194:             *@param  region                 The region that should have the border
195:             *@param  workbook               The workbook that the region is on.
196:             *@param  sheet                  The sheet that the region is on.
197:             *@exception  NestableException  Thrown if the CellStyle can't be changed
198:             */
199:            public static void setBorderTop(short border, Region region,
200:                    HSSFSheet sheet, HSSFWorkbook workbook)
201:                    throws NestableException {
202:                int colStart = region.getColumnFrom();
203:                int colEnd = region.getColumnTo();
204:                int rowIndex = region.getRowFrom();
205:                HSSFRow row = HSSFCellUtil.getRow(rowIndex, sheet);
206:                for (int i = colStart; i <= colEnd; i++) {
207:
208:                    HSSFCell cell = HSSFCellUtil.getCell(row, i);
209:                    HSSFCellUtil.setCellStyleProperty(cell, workbook,
210:                            "borderTop", new Short(border));
211:                }
212:            }
213:
214:            /**
215:             *  Sets the topBorderColor attribute of the HSSFRegionUtil object
216:             *
217:             *@param  color                  The color of the border
218:             *@param  region                 The region that should have the border
219:             *@param  workbook               The workbook that the region is on.
220:             *@param  sheet                  The sheet that the region is on.
221:             *@exception  NestableException  Thrown if the CellStyle can't be changed
222:             *      properly.
223:             */
224:            public static void setTopBorderColor(short color, Region region,
225:                    HSSFSheet sheet, HSSFWorkbook workbook)
226:                    throws NestableException {
227:                int colStart = region.getColumnFrom();
228:                int colEnd = region.getColumnTo();
229:                int rowIndex = region.getRowFrom();
230:                HSSFRow row = HSSFCellUtil.getRow(rowIndex, sheet);
231:                for (int i = colStart; i <= colEnd; i++) {
232:                    HSSFCell cell = HSSFCellUtil.getCell(row, i);
233:                    HSSFCellUtil.setCellStyleProperty(cell, workbook,
234:                            "topBorderColor", new Short(color));
235:
236:                }
237:            }
238:
239:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.