Issue #12404 has been updated by Nobuyoshi Nakada.

File bug-12404.log added
Description updated
Status changed from Open to Feedback
Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: DONTNEED, 2.2: DONTNEED, 2.3: UNKNOWN

Maybe related to [Bug #11880]?
Try 2.3.1.

----------------------------------------
Bug #12404: Segmentation fault in ruby 2.3.0p0
https://bugs.ruby-lang.org/issues/12404#change-58765

* Author: Justin Peal
* Status: Feedback
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.0p0 (2015-12-25 revision 53290) [x64-mingw32]
* Backport: 2.1: DONTNEED, 2.2: DONTNEED, 2.3: UNKNOWN
----------------------------------------
Content of genexcel.rb (Can run in Ruby 2.2 x64)

```ruby
#!/usr/bin/env ruby
# encoding: utf-8

require 'win32ole'

class Member
  def full_path xls_name
    File.expand_path(xls_name.encode('gb18030')).encode('utf-8').gsub('/', "\\")
  end

  def book excel, txt_name, xls_name
    workbook = excel.Workbooks.Add
    begin
      worksheet = workbook.worksheets(1)
      worksheet.Name = '成表'
      worksheet.Rows.RowHeight = 20
      worksheet.Range("A2").select
      begin
        excel.ActiveWindow.FreezePanes = true
      rescue
      end
      worksheet.Cells.Font.Size = 9
      widths = [3, 3, 3, 5.63, 7.00, 3.75, 9, 3.75, 3.75, 5.63, 3.75, 3.75, 3.75, 3.75]
      titles = %w{ 号 CXO 上点 昵称 性 手机号 区 街道 社区 数 本  金}
      worksheet.Range("G:G").NumberFormat = '@'
      ('A'..'N').each_with_index do |column, index|
        worksheet.Range("#{column}1").ColumnWidth = widths[index]
        worksheet.Range("#{column}1").Value = titles[index]
      end
      line = 1
      File.open(txt_name, 'r:gb18030') do |fil|
       fil.each_line do |row|
          line += 1
          columns = row.chomp.split("\t")
          ('A'..'N').each_with_index do |column, index|
            worksheet.Range("#{column}#{line}").Value = columns[index]
          end
       end
      end
      worksheet.Range("A1:N#{line}").HorizontalAlignment = 1
      worksheet.Range("A1:N#{line}").VerticalAlignment = 2     # (1~5)
      worksheet.Range("A1:N#{line}").Borders.Weight = 2
      worksheet.Range("A1:N#{line}").Borders.ColorIndex = 1
      worksheet.Range("A1:N#{line}").Borders.LineStyle = 1     # (1~13)
      worksheet.Range("A1:N1").Interior.ColorIndex = 39
      worksheet.Range("A2:N#{line}").Interior.ColorIndex = 2
      workbook.saveas(full_path(xls_name))
    ensure
      workbook.close
    end
  end

  def main txt_name, xls_name
    WIN32OLE.codepage = WIN32OLE::CP_UTF8
    excel = WIN32OLE::new('ket.Application')   # http://bbs.wps.cn/thread-22427901-1-1.html
    begin
      # excel.AskToUpdateLinks WPS不
      excel.Visible = excel.DisplayAlerts = excel.ScreenUpdating = false
      excel.SheetsInNewWorkbook = 1
      File.delete(xls_name) if File.exist?(xls_name)
      book excel, txt_name, xls_name
    ensure
      excel.Quit
    end
  end
end

if $0 == __FILE__
  Dir.chdir 'C:/K/Hike'
  Member.new.main('simple.txt', 'simple.xls')
end
```


---Files--------------------------------
genexcel.rb (2.31 KB)
bug-12404.log (27.9 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>