modResponseFile 函式庫 風禹科技驗證有限公司 網站 提供 .Net 原始碼

ResponseFile 函數

說明

依內容設定輸出檔案或圖片

本函數之引數列表

引數 型態 位元組 選項 預設值 說明
vOutput Variant - 必須 (無) 若為字串,則輸出文字檔,否則輸出二進位檔
sContentType String - 必須 (無) ContentType 字串
sFileName String - 必須 (無) 輸出檔名
bSaveFile Boolean 2 必須 (無) 是否強制存檔,若否則依瀏覽器預設開啟或存檔

範例

ResponseFile tBytes, "image/png", "xy_" & Trim(Title) & ".png", False
ResponseFile outText, "application/x-msoutlook", sTitle & ".vcf", False
ResponseFile outText, "application/x-msoutlook", sTitle & ".vcs", False

更進一步

若 tBytes 為 png 圖檔二進位陣列

  1. ResponseFile tBytes, "image/png", "xy_" & Trim(Title) & ".png", False
  2. 若強制存檔設定為 False ,則將自動透過網頁瀏覽器開啟圖檔,如 IE

    ResponseFile tBytes, "image/png", "xy_" & Trim(Title) & ".png", True

    若強制存檔設定為 True ,則將不使用瀏覽器展示,並跳出詢問對話框詢問圖檔是否儲存,即使選擇開啟,亦將改依系統預設軟體開啟,如 ACDSee。

    線上執行範例可參考水文統計線上分析

若 outText 為不同之字串內容

  1. ResponseFile outText, "application/x-msoutlook", sTitle & ".vcf", False
  2. 本例為連絡人,由於 IE 並不認得 vcf 格式,仍會自動跳出檔案下載畫面,選擇開啟後,自動由 Outlook 顯示,若選擇儲存後關閉,則會加入 Outlook 連絡人清單,適用於 Outlook/Outlook Express 或支援 vcf 格式之軟體。

  3. ResponseFile outText, "application/x-msoutlook", sTitle & ".vcs", False
  4. 本例為行事曆,由於 IE 並不認得 vcs 格式,仍會自動跳出檔案下載畫面,選擇開啟後,自動由 Outlook 顯示,若選擇儲存後關閉,則會加入 Outlook 行事曆中,含約會排程衝突等,僅適用於 Outlook 或支援 vcs 格式之軟體。

    行事曆相關程式碼可參考 Microsoft Outlook Calendar 行事曆輸出模組,線上執行範例可參考演講與研討會行事曆

基本條件

Internet Information Server 4.0 以後 | ResponseFile.asp

請參閱

modResponseFile 函式庫 | ResponseFile (ASP.NET)