省略表示

SpreadJSは、セルのテキストがセルの幅または高さを超えている場合に、テキストの省略表示をサポートしています。

showEllipsis を設定するだけでテキストを省略表示するかどうかを制御することができます。 任意のセルを選択して右側のプロパティを変更し、セルのスタイルがどのように変化するか試してみてください。 テキストが列幅よりも長い場合に、テキストをオーバーフローではなく省略表示させるには、以下のように設定します。 表示されないテキストは「…」に置き換えられます。 以下の設定は、省略記号の表示方法に影響します。 インデント 縦書きテキスト テキストの配置 パディング アウトライン列
window.onload = function () { var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), { sheetCount: 1 }); initSpread(spread); }; function initSpread(spread) { spread.fromJSON(data); var sheet = spread.getActiveSheet(); document.getElementById('HAlign0').onclick = function () { var style = sheet.getActualStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); style.hAlign = 0; sheet.setStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), style); }; document.getElementById('HAlign1').onclick= function () { var style = sheet.getActualStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); style.hAlign = 1; sheet.setStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), style); }; document.getElementById('HAlign2').onclick = function () { var style = sheet.getActualStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); style.hAlign = 2; sheet.setStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), style); }; document.getElementById('VAlign0').onclick = function () { var style = sheet.getActualStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); style.vAlign = 0; sheet.setStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), style); }; document.getElementById('VAlign1').onclick = function () { var style = sheet.getActualStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); style.vAlign = 1; sheet.setStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), style); }; document.getElementById('VAlign2').onclick = function () { var style = sheet.getActualStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); style.vAlign = 2; sheet.setStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), style); }; document.getElementById('IndentUp').onclick = function () { var style = sheet.getActualStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); if (!isNaN(parseInt(style.textIndent))) { style.textIndent = (parseInt(style.textIndent) + 1) + ""; } else if (style.textIndent === undefined) { style.textIndent = '1'; } sheet.setStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), style); }; document.getElementById('IndentDwon').onclick = function () { var style = sheet.getActualStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); if (!isNaN(parseInt(style.textIndent)) && parseInt(style.textIndent) > 0) { style.textIndent = (parseInt(style.textIndent) - 1) + ""; } sheet.setStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), style); }; document.getElementById('Vertical').onclick = function () { var style = sheet.getActualStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); style.isVerticalText = true; style.textOrientation = 0; sheet.setStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), style); }; document.getElementById('Normal').onclick = function () { var style = sheet.getActualStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); style.isVerticalText = undefined; style.textOrientation = undefined; sheet.setStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), style); }; document.getElementById('SetPadding').onclick = function () { var style = sheet.getActualStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); style.cellPadding = document.getElementById('Top').value + ' ' + document.getElementById('Right').value + ' ' +document.getElementById('Bottom').value + ' '+document.getElementById('Left').value; sheet.setStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), style); }; document.getElementById('ShowEllipsis').onclick = function () { var style = sheet.getActualStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); style.showEllipsis = true; sheet.setStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), style); }; document.getElementById('RemoveEllipsis').onclick = function () { var style = sheet.getActualStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); style.showEllipsis = undefined; sheet.setStyle(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), style); }; }
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta name="spreadjs culture" content="ja-jp" /> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/ja/purejs/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/ja/purejs/node_modules/@mescius/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/ja/purejs/node_modules/@mescius/spread-sheets-resources-ja/dist/gc.spread.sheets.resources.ja.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/js/license.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/data/ellipsis.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 class="options-container"> <div class="option-row"> <label id="Text Oriention" for="textOriention">省略記号の表示:</label> <input type="button" value="表示する" id="ShowEllipsis" /> <input type="button" value="表示しない" id="RemoveEllipsis" /> </div> <div class="option-row"> <label id="Text Oriention" for="textOriention">水平位置:</label> <input type="button" value="左揃え" id="HAlign0" /> <input type="button" value="中央揃え" id="HAlign1" /><br> <input type="button" value="右揃え" id="HAlign2" /> </div> <div class="option-row"> <label id="Text Oriention" for="textOriention">垂直位置:</label> <input type="button" value="上揃え" id="VAlign0" /> <input type="button" value="中央揃え" id="VAlign1" /><br> <input type="button" value="下揃え" id="VAlign2" /> </div> <div class="option-row"> <label id="Text Oriention" for="textOriention">インデント:</label> <input type="button" value="挿入する" id="IndentUp" /> <input type="button" value="削除する" id="IndentDwon" /> </div> <div class="option-row"> <label id="Text Oriention" for="textOriention">縦書きテキスト:</label> <input type="button" value="縦書き" id="Vertical" /> <input type="button" value="ノーマル" id="Normal" /> </div> <div class="option-row"> <label id="Text Oriention" for="textOriention">パディング:</label> <table> <tr> <td> <label class="paddingLabel1">Top:</label><input class="paddingInput1" id="Top" type="number"/><br> </td> <td> <label class="paddingLabel1">Right:</label><input class="paddingInput1" id="Right" type="number"/><br> </td> </tr> <tr> <td> <label class="paddingLabel1">Bottom:</label><input class="paddingInput1" id="Bottom" type="number"/><br> </td> <td> <label class="paddingLabel1">Left:</label><input class="paddingInput1" id="Left" type="number"/> </td> </tr> </table> <input style="margin-left: 117px;" id="SetPadding" type="button" value="設定"/> </div> </div> </div> </body> </html>
.sample-tutorial { position: relative; height: 100%; overflow: hidden; } .sample-spreadsheets { width: calc(100% - 280px); height: 100%; overflow: hidden; float: left; } .options-container { float: right; width: 280px; padding: 12px; height: 100%; box-sizing: border-box; background: #fbfbfb; overflow: auto; } input { width: 100px; } .option-row { font-size: 14px; padding: 5px; } label { display: block; padding-bottom: 5px; } input { padding: 4px 6px; margin-bottom: 6px; margin-right: 10px; } .paddingLabel { width: 113px; display: inline-block; text-align: center; } .paddingLabel1 { width: 50px; /* display: inline-block; */ } .paddingInput { width: 84px; } .paddingInput1 { width: 84px; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; }