Can the text of a roll table be trimmed with ruby?

Is there a way to use the ruby ​​sheet of a spreadsheet to create a spreadsheet with a cell whose text is wrapped? (If not, is there any other way to do this?)

Thanks, --Paul

ps In response to two good suggestions, which, unfortunately, will not work for me, I should note: 1) I can not convert my ruby ​​application to JRuby at this time. 2) I am developing Linux, not Windows.

+3
source share
4 answers

Try this for a Ruby spreadsheet gem:

 fmt = Spreadsheet::Format.new :text_wrap => true
 sheet.row(y).set_format(x, fmt)

here:

http://rubyforge.org/forum/forum.php?set=custom&forum_id=2920&style=nested&max_rows=50&submit=Change+View

+8
source

Phrogz , Win32OLE , . Win32OLE:

worksheet.Range("A1").WrapText = true      , worksheet .

:

xl = WIN32OLE.new('Excel.Application')      # => opens Excel
wb = xl.Workbooks.Add();                    # => adds a workbook
worksheet = wb.Worksheets(3)                # => 3rd sheet (Excel starts at 1)
worksheet.Range("A1").value = "Hello, how do you do?"
worksheet.Range("A1").WrapText = true       # => wraps the text    

, . Win32OLE Excel .

P.S. -, , , .


EDIT: Linux, Linux.

, , , POI Ruby Bindings:

h = Poi4r::HSSFWorkbook.new
s = h.createSheet("Sheet1")
r = s.createRow(0)
c = r.createCell(0)

t = h.createCellStyle()
t.setWrapText(true)

. POI Ruby POI.

+2

Instead of using a spreadsheet - which generates a spreadsheet from scratch with disabilities - I suggest using Win32OLE for an Excel script to modify an existing file. This only works if you are on Windows and have a copy of Excel that Ruby can open and therefore is usually not suitable for a server environment.

-1
source

Source: https://habr.com/ru/post/1783523/


All Articles