Source Code Cross Referenced for ExcelDataFormat.java in  » Database-Client » SQL-Workbench » workbench » db » exporter » 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 » Database Client » SQL Workbench » workbench.db.exporter 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ExcelDataFormat.java
003:         *
004:         * This file is part of SQL Workbench/J, http://www.sql-workbench.net
005:         *
006:         * Copyright 2002-2007, Thomas Kellerer
007:         * No part of this code maybe reused without the permission of the author
008:         *
009:         * To contact the author please send an email to: support@sql-workbench.net
010:         *
011:         */
012:        package workbench.db.exporter;
013:
014:        import org.apache.poi.hssf.usermodel.HSSFCellStyle;
015:        import org.apache.poi.hssf.usermodel.HSSFDataFormat;
016:        import org.apache.poi.hssf.usermodel.HSSFFont;
017:        import org.apache.poi.hssf.usermodel.HSSFWorkbook;
018:
019:        /**
020:         * @author Alessandro Palumbo
021:         */
022:        class ExcelDataFormat {
023:            protected String decimalFormat;
024:            protected String dateFormat;
025:            protected String tsFormat;
026:            protected String integerFormat;
027:            protected HSSFCellStyle headerCellStyle = null;
028:            protected HSSFCellStyle dateCellStyle = null;
029:            protected HSSFCellStyle tsCellStyle = null;
030:            protected HSSFCellStyle decimalCellStyle = null;
031:            protected HSSFCellStyle integerCellStyle = null;
032:            protected HSSFCellStyle textCellStyle = null;
033:            protected HSSFDataFormat dataFormat = null;
034:            protected short gridDateFormat;
035:            protected short gridDecimalFormat;
036:            protected short gridIntegerFormat;
037:            protected short gridTsFormat;
038:
039:            public ExcelDataFormat(String decimalFormat, String dateFormat,
040:                    String integerFormat, String tsFormat) {
041:                this .decimalFormat = decimalFormat;
042:                this .dateFormat = dateFormat;
043:                this .integerFormat = integerFormat;
044:                this .tsFormat = tsFormat;
045:            }
046:
047:            protected void setupWithWorkbook(HSSFWorkbook wb) {
048:                dataFormat = wb.createDataFormat();
049:                setUpHeader(wb);
050:                setUpText(wb);
051:                setUpDate(wb);
052:                setUpDecimal(wb);
053:                setUpInteger(wb);
054:                setUpTs(wb);
055:            }
056:
057:            protected void setUpText(HSSFWorkbook wb) {
058:                textCellStyle = wb.createCellStyle();
059:                textCellStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT);
060:                textCellStyle.setWrapText(true);
061:            }
062:
063:            protected void setUpDate(HSSFWorkbook wb) {
064:                dateCellStyle = wb.createCellStyle();
065:                dateCellStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT);
066:                gridDateFormat = safeGetFormat(dataFormat, dateFormat);
067:                dateCellStyle.setDataFormat(gridDateFormat);
068:            }
069:
070:            protected void setUpDecimal(HSSFWorkbook wb) {
071:                decimalCellStyle = wb.createCellStyle();
072:                decimalCellStyle.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
073:                gridDecimalFormat = safeGetFormat(dataFormat, decimalFormat);
074:                decimalCellStyle.setDataFormat(gridDecimalFormat);
075:            }
076:
077:            protected void setUpInteger(HSSFWorkbook wb) {
078:                integerCellStyle = wb.createCellStyle();
079:                integerCellStyle.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
080:                gridIntegerFormat = safeGetFormat(dataFormat, integerFormat);
081:                integerCellStyle.setDataFormat(gridIntegerFormat);
082:            }
083:
084:            protected void setUpHeader(HSSFWorkbook wb) {
085:                headerCellStyle = wb.createCellStyle();
086:                HSSFFont font = wb.createFont();
087:                font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
088:                headerCellStyle.setFont(font);
089:                headerCellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
090:            }
091:
092:            protected void setUpTs(HSSFWorkbook wb) {
093:                tsCellStyle = wb.createCellStyle();
094:                tsCellStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT);
095:                gridTsFormat = safeGetFormat(dataFormat, tsFormat);
096:                tsCellStyle.setDataFormat(gridTsFormat);
097:            }
098:
099:            protected static short safeGetFormat(HSSFDataFormat dataFormat,
100:                    String formatString) {
101:                short format = HSSFDataFormat.getBuiltinFormat(formatString);
102:                if (format < 0) {
103:                    // It's not a builtin format, need to create
104:                    format = dataFormat.getFormat(formatString);
105:                }
106:                return format;
107:            }
108:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.