在該 討論 發現,原來是檔案總管的預覽視窗造成,關閉預覽視窗就恢復正常
軟體相關資訊:
- OS:Win11 25H2
- Office:2013 (15.0.5603.1000)
結果的空間不足,無法將 money (貨幣) 值轉換成 smallmoney。該欄位資料型態是 smallmoeny,很明顯是 sum 結果超過 smallmoney 資料範圍導致的異常,samllint 資料範圍在 -214,748.3648 到 214,748.3647 之間,但意外的是為什麼針對 smallmoney 欄位進行 sum 時是回傳 moeny 資料型態
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
function doGet() {
return HtmlService.createHtmlOutputFromFile('Index')
.setTitle('kjua QRCode 產生器');
}
<!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>
/**
* 測試與執行範例:呼叫共用模組並儲存到 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;
}
}