Posted 8 September 2017, 9:52 am EST
Does SpreadJS support text rotation like sheet.getCell(1, 1).rotate(90) ?
Forums Home / Spread / SpreadJS
Posted by: sade on 8 September 2017, 9:52 am EST
Posted 8 September 2017, 9:52 am EST
Does SpreadJS support text rotation like sheet.getCell(1, 1).rotate(90) ?
Posted 8 September 2017, 9:52 am EST
Hello,
Unfortunately, it is not possible with Spread JS api as of now. Hence it has already been posted as enhancement. It might be implemented in the future releases if the development team finds it to be feasible.
Thanks,
Manpreet Kaur
Posted 8 September 2017, 9:52 am EST
It is possible to rotate text through custom celltype, here is a sample: http://embed.plnkr.co/hj7Enz/
Posted 8 September 2017, 9:52 am EST
Thank you. It works great.
I have another question. I create a combobox in a cell. I can select the item and use its value in other cells’ formulas. What about creating another combobox based on the first one? I want to add a combobox with country names and when I select a country, I want another combobox to be created with that country’s cities.
Posted 8 September 2017, 9:52 am EST
You may do it by using code, when country combobox changed, update items in city combobox, may do it in CellChanged event: http://helpcentral.componentone.com/NetHelp/SpreadHClientUG/webframe.html#Spread~$.wijmo.wijspread.Events~CellChanged_EV.html
Another way is using validation list, here is sample of Excel, you may do same in SpreadJS.
http://www.excel-easy.com/examples/dependent-drop-down-lists.html
Hope it helps
Posted 8 September 2017, 9:52 am EST
Thank you. I used the first approach and it helped a lot.
For those who may need such thing;
[js]
var country_list = {
“US”: [‘Select’,‘Washington’,‘New York’,‘Seattle’],
“UK”: [‘Select’,‘London’,‘Manchester’,‘Liverpool’],
};
var country = new $.wijmo.wijspread.ComboBoxCellType(); country.items( country_list['US'] ); sheet.getCell(4, 9).cellType(country); $("#ss").wijspread("spread").getActiveSheet().bind($.wijmo.wijspread.Events.CellChanged, function (e, info) { if(info.sheetArea === $.wijmo.wijspread.SheetArea.viewport && info.col == 7){ country.items( country_list[ sheet.getCell(info.row , info.col).text() ] ); sheet.getCell(4, 9).text(''); } });
[/js]
Posted 5 December 2018, 4:39 pm EST
This works great for rotating the text, is there a way for the text to maintain other style options when rotated such as font size and color
Posted 5 December 2018, 5:01 pm EST
I was able to solve my issue, I just have to pass the style values from the function to the canvas ```
ctx.beginPath();
ctx.translate(x, y);
ctx.rotate(-0.5 * Math.PI);
ctx.fillStyle = style.foreColor;
ctx.font = style.font;
ctx.fillText(value, 0, 0);
ctx.restore();