撰寫一支asp,內容如下
<%
Response.AddHeader "Content-Disposition", "attachment; filename=機關成員名單.xls"
Response.ContentType = "application/ms-excel"
%>
<table border="1">
<tr>
<td>編號</td>
<td>姓名</td>
<td>機關名稱</td>
<td>機關代碼</td>
<td>日期1</td>
<td>日期2</td>
</tr>
<tr>
<td>1</td>
<td>小明</td>
<td>日光燈有限公司</td>
<td style="mso-number-format:\@">0012</td>
<td style="mso-number-format:yyyy\/m\/d;\@"><%=date%></td>
<td style="mso-number-format:yyyy\"\年\"m\"\月\"d\"\日\";\@"><%=date%></td>
</tr>
</table>
<%
Response.Flush
Response.Clear
%>
說明:
1. Response.ContentType 設定輸出為 Excel
2. Response.AddHeader 用來將結果輸出成檔案,「attachment;」不加的話會變成直接由瀏覽器開啟,「filename=」用來設定檔案名稱
3. Table 的表格相對應 Excel 的儲存格
4. 若要設定儲存格格式(如文字、日期格式),則在
加上style屬性,並且設定mso-number-format值。 mso-number-format 的參考方式可以利用將 Excel 另存成 XML 試算表,然後用 notepad 開啟該檔案,並參考檔案中該 Cell 所設定的 Style 如:,將「mm/dd/yy;@」套用到上面的 mso-number-format 即可。 但是特殊字元前必需加上反斜線「\」,所以正確格式為:「mm\/dd\/yy;\@」。 註: 特殊字元如:中文字、「/」、「@」、「&」...等。
參考來源: http://www.codeproject.com/aspnet/DAtaGridExportToExcel.asp
try { Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=dbname"; Connection con = DriverManager.getConnection(url, "userid", "password"); Statement stmt = con.createStatement(1004, 1008); } catch(Exception e) { e.printStackTrace(); }
必要的 JAR 檔來源:到 Microsoft Download Center輸入關鍵字 jdbc 找 SQL Server 2000 Driver for JDBC Service Pack 3 下載安裝 將安裝目錄下的三個 jar (msbase.jar、mssqlserver.jar、msutil.jar) 放到所需的 lib 目錄下即可。
參考文章 Install the Active Directory Schema snap-in
- Open Command Prompt.
- Type:
regsvr32 schmmgmt.dll
This command will register schmmgmt.dll on your computer. For more information about using regsvr32, see Related Topics.
- Click Start, click Run, type mmc /a, and then click OK.
- On the File menu, click Add/Remove Snap-in, and then click Add.
- Under Available Standalone Snap-ins, double-click Active Directory Schema, click Close, and then click OK.
- To save this console, on the File menu, click Save.
- In Save in, point to the systemroot\system32 directory.
- In File name, type schmmgmt.msc, and then click Save.
- To create a shortcut on your Start menu:
- Right-click Start, click Open All Users, double-click the programs folder, and then double-click the Administrative Tools folder.
- On the File menu, point to New, and then click Shortcut.
- In the Create Shortcut Wizard, in Type the location of the item, type schmmgmt.msc, and then click Next.
- On the Select a Title for the program page, in Type a name for this shortcut, type Active Directory Schema, and then click Finish.
想要讓 MSN 顯示 Foobar2000 正在播放的歌嗎? 1. 到 MSN Messenger Now Playing Plugin 下載 foo_msn 元件 2. 將 foo_msn.dll 放到 C:\Program Files\foobar2000\components 目錄下 3. 重新啟動 Foobar2000 即可 開啟 Foobar2000->Preferences,在 Components->MSN Now Playing 中可做設定
|