zdavatz / spreadsheet

The Ruby Spreadsheet by ywesee GmbH
http://spreadsheet.ch
GNU General Public License v3.0
1.13k stars 240 forks source link

Default columns number less then 5 #244

Closed vergilet closed 5 years ago

vergilet commented 5 years ago

I want to generate new XLS file with 3 column, but it generates 5 columns. Can anyone help me with this? Are there any options to set that? Thanks.

zdavatz commented 5 years ago

Have you read this? https://github.com/zdavatz/spreadsheet/blob/master/GUIDE.md

vergilet commented 5 years ago

Can you please point me at exact place in the GUIDE?

zdavatz commented 5 years ago

Does this help you: https://stackoverflow.com/questions/39986323/ruby-spreadsheet-getting-column-count-in-xls-file/39986936

vergilet commented 5 years ago

@zdavatz,

Sorry, maybe I have described my case unclearly. To generate a new XLS I use the following code:

    book = Spreadsheet::Workbook.new
    sheet = book.create_worksheet

    header = ['col_1, 'col_2', 'col_3']
    sheet.row(0).concat(header)

    spreadsheet = StringIO.new
    book.write(spreadsheet)

    spreadsheet.string

I am expecting to receive the next screen:

Знімок екрана 2019-09-14 о 22 20 28

But I receives table with two extra columns:

Знімок екрана 2019-09-14 о 22 21 48

The only solution I came up is to merge column 3 with 4th and 5th:

sheet.merge_cells(0, 2, 0, 4)

But I believe I am missing something. Any suggestions? Thanks.

zdavatz commented 5 years ago

with which software do you open the file?

vergilet commented 5 years ago

I use Numbers App (https://www.apple.com/uk/numbers/) Now I see that it could be the problem with software.

Thanks for help! Closing it.

zdavatz commented 5 years ago

Try LibreOffice.