The SJS.AI.TRANSLATE function translate an array based on a specified language. For example:
Argument
Required
Description
array
Y
The array, or range to translate
language
Y
The specified language
The SJS.AI.QUERY function allows to query result from AI model with given value. For example:
Argument
Required
Description
prompt
Y
The action that you want AI model to do.
array
Y
The array, or range that you want apply the action
The SJS.AI.TEXTSENTIMENT function Returns the sentiment of text as Positive, Negative, or Neutral. For example:
Argument
Required
Description
array
Y
The array, or range to analyze
positive
Y
The return value if the text sentiment is Positive
negative
Y
The return value if the text sentiment is Negative
neutral
N
The return value if the text sentiment is Neutral
Note:
The AI functions is only valid when allowDynamicArray is true.
AI-Generated Content Disclaimer
1. Content Generation Risks
This service utilizes third-party AI models injected by users to generate outputs. Results may contain inaccuracies, omissions,或 misleading content due to inherent limitations in model architectures and training data. While we implement prompt engineering and technical constraints to optimize outputs, we cannot eliminate all error risks stemming from fundamental model deficiencies.
2. User Verification Obligations
By using this service, you acknowledge and agree to:
Conduct manual verification of all generated content
Refrain from using unvalidated outputs in high-risk scenarios (legal, medical, financial, etc.)
Hold us harmless for any direct/indirect damages caused by reliance on generated content
3. Technical Limitations
We disclaim responsibility for:
Output failures caused by third-party model defects or logic errors
Unsuccessful error recovery attempts through fault-tolerant procedures
Technical constraints inherent in current AI technologies
4. Intellectual Property Compliance
You must ensure:
Injected models/content do not infringe third-party rights
No illegal/sensitive material is processed through the service
Compliance with model providers' IP agreements
5. Agreement Updates
We reserve the right to modify these terms to align with:
Technological advancements (e.g. new AI safety protocols)
Regulatory changes (e.g. updated AI governance frameworks)
Service architecture improvements
window.onload = function () {
var spread = new GC.Spread.Sheets.Workbook(_getElementById("ss"));
injectAI(spread);
initSpread(spread);
};
function initSpread(spread) {
spread.options.allowDynamicArray = true;
var sheet = spread.getActiveSheet();
spread.suspendPaint();
spread.suspendCalcService();
const restaurantReviews = [
["Username", "Review"],
[
"Miss Zhang",
"The restaurant offers a beautiful ambiance and attentive service, perfect for family gatherings.",
],
[
"Mr. Li",
"The food is delicious, but the prices are slightly high, which affects the overall value.",
],
[
"Mr. Wang",
"It was noisy with poor service and slow food delivery, making for a disappointing experience.",
],
[
"Emily",
"Loved the unique dishes and inviting atmosphere! Definitely planning to come back.",
],
[
"Ms. Chen",
"Great flavors and a cozy setting, although the waiting time was a bit too long.",
],
[
"Mr. Zhao",
"A varied menu with mixed results; some dishes were outstanding while others were just average.",
],
[
"George",
"The service was extremely poor and the food quality subpar, leaving a very negative impression.",
],
[
"Miss Liu",
"The food was ordinary and the restaurant was too noisy, which detracted from the overall experience.",
],
];
sheet.setArray(0, 0, restaurantReviews);
sheet.setColumnWidth(0, 85)
sheet.setColumnWidth(1, 560);
sheet.setValue(0, 3, "TEXTSENTIMENT");
sheet.setFormula(
1,
3,
'=SJS.AI.TEXTSENTIMENT(B2:B9, "Positive", "Negative")'
);
sheet.setFormula(0, 5, '=SJS.AI.TRANSLATE(A1:B9, "ja-jp")');
sheet.setColumnWidth(6, 180);
const countries = [
["Country", "Please give me the capital of the country"],
["China"],
["India"],
["United States"],
["Indonesia"],
["Pakistan"],
["Brazil"],
["Nigeria"],
["Bangladesh"],
["Russia"],
["Japan"],
];
sheet.setArray(10, 0, countries);
sheet.setFormula(11, 1, "=SJS.AI.QUERY(B11, A12:A21)");
spread.resumeCalcService();
spread.resumePaint();
}
function _getElementById(id) {
return document.getElementById(id);
}
function injectAI(spread) {
const serverCallback = async (requestBody) => {
const response = await fetch(getAIApiUrl(), {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(requestBody)
});
if (response.status === 429) {
alert('The server is busy, please try again later.');
return;
}
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response;
};
spread.injectAI(serverCallback);
}
function getAIApiUrl() {
return window.location.href.match(/http.+spreadjs\/demos\//)[0] + 'server/api/queryAI';
}
<!DOCTYPE html>
<html style="height: 100%; font-size: 14px">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="stylesheet"
type="text/css"
href="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css"
/>
<script
src="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets/dist/gc.spread.sheets.all.min.js"
type="text/javascript"
></script>
<script src="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets-ai-addon/dist/gc.spread.sheets.ai.min.js" type="text/javascript"></script>
<script
src="$DEMOROOT$/spread/source/js/license.js"
type="text/javascript"
></script>
<script src="app.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
<div class="sample-tutorial">
<div id="ss" class="sample-spreadsheets"></div>
</div>
</body>
</html>
.sample-tutorial {
position: relative;
height: 100%;
overflow: hidden;
}
.sample-spreadsheets {
width: 100%;
height: 100%;
overflow: hidden;
float: left;
}
.options-container {
float: right;
width: 280px;
padding: 12px;
height: 100%;
box-sizing: border-box;
background: #fbfbfb;
overflow: auto;
}
.option-row {
font-size: 14px;
padding: 5px;
margin-top: 10px;
}
input {
margin-bottom: 5px;
padding: 2px 4px;
width: 100%;
box-sizing: border-box;
}
body {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}