Author Archives: vincent

POI 列印 Excel 的小技巧

1. 利用 jdk 6 新的 API java.awt.Desktop 列印

以 excel 為例,這個 API 會啟動目前的平台已經登記處理 xls 檔案的程式來列印指定的檔案,sample code 如下:

if ( Desktop.isDesktopSupported() ) {
Desktop desktop=Desktop.getDesktop();
if ( desktop.isSupported(Desktop.Action.PRINT) ) {
desktop.print(excelFile);
}
} else {
System.out.println(“debug: desktop not supported!”);
}

2. 列印 excel 檔案內所有的工作表

利用以上方法列印時,通常只會印出 excel 檔的第一個工作表,如果要印出所有工作表可以利用org.apache.poi.hssf.usermodel.HSSFSheet 的 setSelected method,例如

for(int i=1;i<sheetCount;i++) {

workbook.getSheetAt(i).setSelected(true);

}

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Ubuntu 9.10 安裝筆記

Ubuntu 9.10 在 10/30 已經開放下載了,安裝後的一些問題及改版重點如下:

Part I: Desktop

eclipse 問題

eclipse 3.5.1 安裝軟體的機制無法運作,這個網址有 bug 回報,第13篇有一個執行 eclipse 的 script 可以解決這個問題,我自己寫的一併列出來供大家參考:

#!/bin/sh

ECLIPSE_HOME=/u00/develop/eclipse
export GDK_NATIVE_WINDOWS=1
$ECLIPSE_HOME/eclipse

subclipse 問題

libsvn-java 這個套件昇級到 1.6.5,但是安裝後發現無法 commit 資料到 SVN server,現在已經確認是 subclipse 的 bug。暫時的解決方法是修改 ~/.subversion/config 這個檔案,找到以下這行設定

# password-stores = gnome-keyring,kwallet

修改為

password-stores =

中文輸入法

9.10 把預設的 scim 換成 ibus,安裝中文支援後,先登出再登入就會看到 ibus 的 tray icon。注音輸入可以用酷音,速成輸入法找了好久,原來是標示為 簡ALL 的那一個,也有倉頡可以用,熟悉 scim 的話看一下應該不會有太大的問題。

Virtualization

VMware 10/26 release 的 VMware server 2.0.2 版,剛出來馬上就不能用,compile kernel module 過不了,看來又要等 patch 了。VirtualBox Open Source 版昇級到 3.0.8 版,這個版本穩定又好用,是個不錯的選擇。

Part II: Server

XFCE4

執行 aptitude install xfce4,登入後發現許多 icon 都沒有顯示出來,結果發現是漏了 xfce4-icon-theme 這個套件。

Service 管理

首先可以複製一個 /etc/init.d 下面的 script 來當作範本,ssh 這個檔案是一個很好的例子,要注意的是 script 的 header 及提供 start、stop 2 個 method,然後利用以下指示建立相關 symbolic link 即可:

update-rc.d -f <your script name> defaults

VNC server

目前應該沒有自動執行的 script 和設定檔,最快的方法是在 /etc/rc.local 加入以下這行啟動 vnc server。記得把 vincent 換成實際的 user 帳號,如果有多個 vnc 用戶,必須指定各別的 display number,例如 :1, :2, etc。

/bin/su – vincent -c “/usr/bin/vncserver :1” >/dev/null

reboot 之後 server 起不來

由於 server 沒有裝 console , syslog 也沒有看到異常的 log ,所以確實的原因不明,硬體是比較老舊。參考網路上的一些案例發現 9.10 在 mount / 的 option 是 errors=remount-ro,改成 defaults 之後就沒有再發生了。

常用的 GUI 管理套件

synaptic

update-manager

update-notifier

bum

2009.11.29 加註

VMware Player 3.0 已經內建 VM 新增及管理功能,如果環境單純的話,已經沒有必要再借助 VMware server 了。在 ubuntu 9.10 上執行 VMware server 2.0.2,這個 網址 有測試過確定可用的方案,把下載的 VMware server gz 檔和他的 script 放在同目錄執行 script 就會自動 patch 與進行安裝。

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

Fedora、CentOS 設定 email 通知套件更新

Fedora、CentOS 通常都會執行 yum-updatesd 檢查是否有更新套件,預設是透過 dbus 發佈更新訊息。但是在沒有安裝 Desktop GUI,只有 console 可用的 server 環境,email 通知還是比 dbus 方便。這時候必須修改 /etc/yum/yum-updatesd.conf 設定:

在以下這行前面加 #

emit_via = dbus

然後加入以下幾行設定

emit_via = email

email_to = <收件人 email address>

email_from = <寄件人 email address>

接著重新啟動 yum-updatesd 即可。

參考網站: Red hat / CentOS / Fedora Send Yum Package Update Notification Via Email

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Ubuntu 9.04 安裝 VMware Server 2.0.1 Build 156745

最近在 Ubuntu 9.04 上安裝 VMware Server 2.0.1 Build 156745,執行 vmware-config.pl 時出現 vsock 模組 compile 錯誤的訊息,雖然最後可以進 web interface,但是 VMware Server 的反應很慢,硬碟空間的顯示也不正確。最後在 Ubuntu 的討論區找到 這篇文章 第53篇的 patch 在 Ubuntu 9.04 x64、kernel 2.6.28-14-generic #47 的系統測試後確定是有效的,有同樣困擾的人可以試看看。

附記:

Windows guest 在安裝完 VMware Tools 後會有一個 shrink disk 的功能把 vmdk 檔縮小,我在執行這個功能時出現 ‘The attempt to shrink the disk failed’ 的錯誤,由於縮小的過程是邊讀舊的 vmdk 檔,邊寫出新的 vmdk 檔,我的情形是原 vmdk 檔有 9G 但是硬碟空間只剩 7~8 G 所以沒有足夠的空間可以執行 shrink disk 作業。

Virtualbox 的 VM 是否有啟用 IntelVT-x 或 AMD-V 在 GUI 右下方會有狀態顯示,VMWare 要啟用 IntelVT-x 或 AMD-V 可以在 vmx 設定檔加入以下這行

monitor.virtual_exec = “hardware”

更詳細的說明文件在這個 URL

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...