1: File tempFile = new File(filePath,filename);//建立儲存檔案
2: Workbook workbook = new HSSFWorkbook();//建立Excel物件
3: String safeName = WorkbookUtil.createSafeSheetName(SHEETNAME);
4: Sheet sheet = workbook.createSheet(safeName);//建立工作表
5: Row row1 = sheet.createRow((short)0);//建立工作列
6: //字型設定
7: Font font = workbook.createFont();
8: font.setColor(HSSFColor.WHITE.index);//顏色
9: font.setBoldweight(Font.BOLDWEIGHT_BOLD); //粗體
10: //設定儲存格格式
11: CellStyle styleRow1 = workbook.createCellStyle();
12: styleRow1.setFillForegroundColor(HSSFColor.GREEN.index);//填滿顏色
13: styleRow1.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
14: styleRow1.setFont(font);//設定字體
15: styleRow1.setAlignment(HSSFCellStyle.ALIGN_CENTER);//水平置中
16: styleRow1.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//垂直置中
17: //設定框線
18: styleRow1.setBorderBottom((short)1);
19: styleRow1.setBorderTop((short)1);
20: styleRow1.setBorderLeft((short)1);
21: styleRow1.setBorderRight((short)1);
22: styleRow1.setWrapText(true);//自動換行
23: Cell cell = row1.createCell(0);//建立儲存格
24: cell.setCellStyle(styleRow1);//套用格式
25: cell.setCellValue(CELLTEXT);//設定內容
26: sheet.autoSizeColumn(0);//自動調整欄位寬度
27: //儲存檔案
28: FileOutputStream fileOut = new FileOutputStream(tempFile);
29: workbook.write(fileOut);
30: fileOut.close();
Total Pageviews
2013/11/12
POI 常用API筆記
參考資料來源:http://become.wei-ting.net/2011/11/poiexcel.html
Labels:
POI
How do I do redirect in AngularJS
Question
I would like to do window.location (JavaScript way) to redirect page.
How do I do in AngularJS?
Answer
You can use $window.location.href=[your link]
Example
According to the system analysis specification, system should redirect to specific page based on the option which chose by user.
We can define $window.location.href in js file.
I would like to do window.location (JavaScript way) to redirect page.
How do I do in AngularJS?
Answer
You can use $window.location.href=[your link]
Example
According to the system analysis specification, system should redirect to specific page based on the option which chose by user.
1: <div class="form-group col-sm-5">
2: <label class="control-label">選擇查詢報表 :</label>
3: <select class="form-control" data-ng-change="update()"
4: id="reportName" name="reportName"
5: data-ng-model="model.reportName" >
6: <option value="" >請選擇</option>
7: <option value="ETS401R">收支狀況日報表 (總表)</option>
8: <option value="ETS402R">收支狀況日報表 (支出明細表)</option>
9: <option value="ETS403R">收支狀況日報表 (支入明細表)</option>
10: <option value="ETS407R">年度國庫現金餘額表</option>
11: </select>
12: </div>
1: $scope.update = function(){
2: var reportName = $scope.model.reportName;
3: $window.location.href = '/nss/'+reportName+'/';
4: };
Labels:
AngularJS
How to fix com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException
Exception
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "reportName" (class gov.nta.ets.web.dto.Ets405rFormBean), not marked as ignorable (4 known properties: , "accYy", "type", "data", "funcId"])
at [Source: java.io.ByteArrayInputStream@57a9b75a; line: 4, column: 18] (through reference chain: gov.nta.ets.web.dto.Ets405rFormBean["reportName"])
at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:79) [jackson-databind-2.2.3.jar:]
Root Cause
This exception means that there are get and set methods of an object in your class and Jackson is unable to figure out during serialization and deserialization process.
Solution
Apply @JsonIgnore on getter method, i.e. getReportName
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "reportName" (class gov.nta.ets.web.dto.Ets405rFormBean), not marked as ignorable (4 known properties: , "accYy", "type", "data", "funcId"])
at [Source: java.io.ByteArrayInputStream@57a9b75a; line: 4, column: 18] (through reference chain: gov.nta.ets.web.dto.Ets405rFormBean["reportName"])
at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:79) [jackson-databind-2.2.3.jar:]
Root Cause
This exception means that there are get and set methods of an object in your class and Jackson is unable to figure out during serialization and deserialization process.
Solution
Apply @JsonIgnore on getter method, i.e. getReportName
1: /**
2: * Gets the report name.
3: *
4: * @return the reportName
5: */
6: @JsonIgnore
7: public String getReportName() {
8: return reportName;
9: }
2013/10/17
Windows 無法自動偵測此網路的proxy設定
今天在公司,突然電腦無法上網,出現 "Windows 無法自動偵測此網路的proxy設定 (Windows could not automatically detect this network's proxy settings)"此錯誤訊息
檢查了網路孔沒問題、ip相關設定沒問題,也重開機了,還是無法上網
最後 Google 到兩個指令,依照以下四步驟就可以解決了(只是還是不知道原因是什麼):
- 打開命令提示字元 (open command line)
- 執行 netsh winsock reset (execute netsh winsock reset)
- 執行 netsh int ipv4 reset (execute netsh int ipv4 reset)
- 重開機 (reboot)
Reference:http://answers.microsoft.com/en-us/windows/forum/windows_7-networking/windows-could-not-automatically-detect-this/d243dea1-d1c8-4c4a-ba96-2b49bc9bab1a
Labels:
MicrosoftWindows
2013/09/24
How to Change User in TortoiseSVN
Question
When I authenticate with a Subversion server, the username and password are cached locally so I don't have to keep entering them each time. But I would like to clear username and password data for some reasons, how do I do?
Answer
1. Right Click --> Settings
2. Choose "Saved Data", then click "Clear" button which besides Authentication data. It clear all authentication data, then you can enter another username and password.
Labels:
SVN
2013/09/03
SP2-0734: unknown command beginning "alter tab..." - rest of line ignored.
Problem
I would like to execute a SQL script file with simple alter table script as follows:
But it showed this error message:
I would like to execute a SQL script file with simple alter table script as follows:
But it showed this error message:
1: SQL*Plus: Release 11.2.0.2.0 Production on Tue Sep 3 08:03:36 2013
2: Copyright (c) 1982, 2010, Oracle. All rights reserved.
3: Connected to:
4: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
5: With the Partitioning, Oracle Label Security and Oracle Database Vault options
6: SP2-0734: unknown command beginning "alter tab..." - rest of line ignored.
7: SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0
8: - 64bit Production
With the Partitioning, Oracle Label
Security and Oracle Database Vault options
Root Cause
It resulted from the SQL file has BOM character:
Solution
What you need to do is to convert the encoding of SQL file to UTF-8 without BOM and execute again, then this problem will be resolved.
Labels:
Oracle
2013/08/28
Utilize ime-mode property to Control Input Method Editor
Problem
Customer asked to control textfield1 can only fill in alphanumeric, textfield2 can fill in alphanumeric and Tranditional Chinese
Solution
We can use ime-mode CSS property to controls the state of the input method editor for text fields.
The default value of ime-mode property is auto, it means "no change is made to the current input method editor state".
If you would like to disable input method editor to allow for numbers and alphabets only, set the property of ime-mode property to "disabled".
If you would like to activate input method editor to allow for numbers, alphabets, and Tranditional Chinese, set the property of ime-mode property to "active".
Demo
Pay attention to some properties do not be supported by specific browser.
Reference: https://developer.mozilla.org/en-US/docs/Web/CSS/ime-mode
Customer asked to control textfield1 can only fill in alphanumeric, textfield2 can fill in alphanumeric and Tranditional Chinese
Solution
We can use ime-mode CSS property to controls the state of the input method editor for text fields.
The default value of ime-mode property is auto, it means "no change is made to the current input method editor state".
If you would like to disable input method editor to allow for numbers and alphabets only, set the property of ime-mode property to "disabled".
If you would like to activate input method editor to allow for numbers, alphabets, and Tranditional Chinese, set the property of ime-mode property to "active".
Demo
Reference: https://developer.mozilla.org/en-US/docs/Web/CSS/ime-mode
Labels:
HTML
2013/08/23
2013/08/16
2013/08/08
2013/08/03
2013/07/24
ORA-01452: cannot CREATE UNIQUE INDEX;
Problem
As DBA rebuilt index, it produced error report as following:
Root Cause
Based on the NIGT021 schema, it only has one primary key. Therefore, it may has abnormal and duplicate data in NIGT021.
Solution
1. Figure out abnormal data
2. Delete abnormal data
3. rebuild index
Here is the SQL statement template to find duplicate value in this table
As DBA rebuilt index, it produced error report as following:
Root Cause
Based on the NIGT021 schema, it only has one primary key. Therefore, it may has abnormal and duplicate data in NIGT021.
Solution
1. Figure out abnormal data
2. Delete abnormal data
3. rebuild index
Here is the SQL statement template to find duplicate value in this table
select column_name, count(column_name)
from [table]
group by column_name
having count (column_name) > 1;
Here is an example to apply to NIGT021 select pnsh_tp, count(pnsh_tp)
from nigt021
group by pnsh_tp
having count (pnsh_tp) > 1;
Labels:
Oracle
2013/07/20
2013/06/22
2013/05/24
Utilize SVN relocate to change repository's root URL
Problem
Administrator changed the location of repository for some reason. The content of the repository doesn't change, but the repository's root URL does.
If we utilized old URL, it will show failed error message as bellows:
Administrator changed the location of repository for some reason. The content of the repository doesn't change, but the repository's root URL does.
If we utilized old URL, it will show failed error message as bellows:
Solution
We can use "SVN relocate" to change the repository's root URL.
Step1. Right Click --> TortoiseSVN -->Relocate
Step2. Change the repository's root URL, and click OK
Then you will get successful dialog as bellows:
Finally, we do SVN update to test if it works or not
Labels:
SVN
2013/05/01
2013/05 Singapore
Singapore flyer
Singapore flyer
Singapore Foods
Singapore早餐必備兩顆生雞蛋
The Jewelry Box
Bird view from Jewelry Box
Universal Studio
S.E.A Aquarium
Singapore Zoo
Singapore Botanic Gardens
Singapore 夜景
Singapore 夜景
Singapore 夜景
Labels:
Travel
2013/04/23
Top 10 Traits of a Rockstar Software Engineer
- Loves To Code
- Gets Things Done
- Continuously Refactors Code
- Uses Design Patterns
- Writes Tests
- Leverages Existing Code
- Focuses on Usability
- Writes Maintainable Code
- Can Code in Any Language
- Knows Basic Computer Science
Subscribe to:
Posts (Atom)