星期二, 8月 25, 2026

[Word] Word 無法啟動 (24)

使用者回報,開啟 Word 檔案時都會出現錯誤訊息,但檔案是打得開,如下圖
在該 討論 發現,原來是檔案總管的預覽視窗造成,關閉預覽視窗就恢復正常

軟體相關資訊:
  • OS:Win11 25H2
  • Office:2013 (15.0.5603.1000)

星期三, 8月 19, 2026

[Gemini] 媒體浮水印

Gemini 官方有開放選項,讓使用者自行選擇是否要有浮水印,個人是還蠻喜歡浮水印,要不然還要特別打上由 AI 生成之類的警語

星期四, 7月 30, 2026

[SQL] 隱含轉換 - 彙總函數回傳值資料型態

一段 sum 並把結果 insert 進 Table TSQL 語法,拋出下面錯誤訊息
結果的空間不足,無法將 money (貨幣) 值轉換成 smallmoney。
該欄位資料型態是 smallmoeny,很明顯是 sum 結果超過 smallmoney 資料範圍導致的異常,samllint 資料範圍在 -214,748.3648 到 214,748.3647 之間,但意外的是為什麼針對 smallmoney 欄位進行 sum 時是回傳 moeny 資料型態
官方文件 - sum return type 內有說明,彙總函式 sum 結果會發生資料型態隱含轉換,以該例來看就是 sum 把 smallmoney 資料彙總時,因為彙總結果超過 smallmoney 資料範圍,所以隱含轉換為 money,insert 回 smallmoney 欄位時拋出錯誤
簡易範例驗證
use tempdb
GO

DROP TABLE IF EXISTS tblDemo

CREATE TABLE tblDemo
(
	ID int identity(1,1) ,
	ColSmallMoney smallmoney
)

INSERT INTO tblDemo (ColSmallMoney) VALUES(214748)
INSERT INTO tblDemo (ColSmallMoney) VALUES(214748)
GO

SELECT 
	SQL_VARIANT_PROPERTY(SUM(ColSmallMoney) , 'BaseType') -- 會得到 money 資料型態
FROM tblDemo

星期三, 7月 22, 2026

[GAS] 使用 JavaScript Library 來產生 QRCode

在 GAS 上使用 JavaScript Linrary - Kjua 來產生 QRCode

code.gs
function doGet() {
  return HtmlService.createHtmlOutputFromFile('Index')
    .setTitle('kjua QRCode 產生器');
}

Index.html
<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
    <!-- 引入 kjua CDN -->
    <script src="https://cdn.jsdelivr.net/npm/kjua@0.10.0/dist/kjua.min.js"></script>
    <style>
      body {
        font-family: Arial, sans-serif;
        text-align: center;
        padding: 40px 20px;
      }
      input {
        padding: 10px;
        font-size: 16px;
        width: 80%;
        max-width: 300px;
        margin-bottom: 10px;
      }
      button {
        padding: 10px 20px;
        font-size: 16px;
        background-color: #4CAF50;
        color: white;
        border: none;
        border-radius: 4px;
        cursor: pointer;
      }
      button:hover {
        background-color: #45a049;
      }
      #qrcode-container {
        margin-top: 30px;
      }
    </style>
  </head>
  <body>
    
    <h2>QRCode 產生器</h2>
    <input type="text" id="text-input" value="https:/www.google.com" placeholder="請輸入要轉換的網址或文字" />
    <br>
    <button onclick="generateQRCode()">產生 QRCode</button>
    
    <!-- QRCode 渲染區域 -->
    <div id="qrcode-container"></div>

    <script>
      function generateQRCode() {
        const textToEncode = document.getElementById('text-input').value;
        const container = document.getElementById('qrcode-container');
        
        // 避免重覆產生 QRCode,每次都先清空
        container.innerHTML = ""; 

        if (!textToEncode) {
          alert("請輸入內容!");
          return;
        }

        // 呼叫 kjua 並產生 QRCode
        const qrCodeElement = kjua({
          render: 'image',   // 渲染為 <img> 標籤
          text: textToEncode,
          size: 250,         // 尺寸設定為 250px
          fill: '#000000',   // QRCode 顏色
          back: '#ffffff',   // 背景顏色
          rounded: 10        // 模組圓角 (0-100),讓外觀看起來更柔和
        });

        container.appendChild(qrCodeElement);
      }
    </script>
    
  </body>
</html>

星期一, 7月 20, 2026

[GAS] 透過第三方 API 產生 QRCode

在 GAS 上使用 goQR.me 第三方服務,該服務只有兩個 API 可以使用,分別為
該筆記只會紀錄使用 create-qr-code 來產生 QRCode 而已
/**
 * 測試與執行範例:呼叫共用模組並儲存到 Google Drive
 */
function testGenerateQRCode() {
  const myData = "https://workspace.google.com/";
  const mySize = 250; // 將會產生 250x250 的 QR Code
    
  const qrBlob = getQRCodeBlob(myData, mySize);
  
  if (qrBlob) {
    const file = DriveApp.getRootFolder().createFile(qrBlob);
    Logger.log(`✅ QR Code 建立成功!檔案連結:${file.getUrl()}`);
  } else {
    Logger.log("❌ 流程中斷:無法取得 QR Code 圖片。");
  }
}

/**
 * 透過 goQR.me (api.qrserver.com) 產生 QR Code 的共用模組
 * 
 * @param {string} textToEncode - 必填:要轉換為 QR Code 的內容(網址或純文字)
 * @param {number} size - 選填:QR Code 的尺寸,預設為 300 (即 300x300 像素)
 * @returns {GoogleAppsScript.Base.Blob|null} 成功時回傳圖片 Blob,失敗則回傳 null
 */
function getQRCodeBlob(textToEncode, size = 300) {
  if (!textToEncode) {
    Logger.log("❌ 錯誤:未傳入 textToEncode 參數");
    return null;
  }

  // 組合 API 網址 (將單一 size 數值轉換為 api.qrserver.com 所需的 "寬x高" 格式)
  const apiUrl = `https://api.qrserver.com/v1/create-qr-code/?size=${size}x${size}&data=${encodeURIComponent(textToEncode)}`;
  
  try {
    const response = UrlFetchApp.fetch(apiUrl, {
      muteHttpExceptions: true
    });
    
    // 驗證並回傳 Blob
    if (response.getResponseCode() === 200) {
      const fileName = `QRCode_${new Date().getTime()}.png`;
      return response.getBlob().setName(fileName);
    } else {
      Logger.log(`❌ 產生失敗,API 伺服器回應狀態碼:${response.getResponseCode()}`);
      return null;
    }
  } catch (error) {
    Logger.log(`❌ 執行階段發生例外狀況:${error.message}`);
    return null;
  }
}