将多维数组写入Excel文件时出现语法错误

时间:2016-03-10 16:52:07

标签: ruby excel rubygems osx-elcapitan

我正在尝试使用El Capitan上的WriteExcel Ruby gem将多维数组写入Excel文件(扩展名Application started. 03-10 10:17:43.185 32527-5764/global.Here.Map.Service.v2 D/NetworkSSLContextFactory: NetworkSSLContextFactory created successfully 03-10 10:17:43.185 32527-5764/global.Here.Map.Service.v2 D/NetworkSSLContextFactory: generateSSlContext BEGIN 03-10 10:17:43.260 32527-5764/global.Here.Map.Service.v2 D/NetworkSSLContextFactory: The number of files 164 found in /storage/emulated/0/.here-maps/certs/ 03-10 10:17:43.767 32527-5764/global.Here.Map.Service.v2 D/NetworkSSLContextFactory: The number of valid certificates 164 03-10 10:17:43.806 32527-5764/global.Here.Map.Service.v2 D/NetworkSSLContextFactory: generateSSlContext END javax.net.ssl.SSLContext@25ec2d22 03-10 10:17:43.809 32527-5764/global.Here.Map.Service.v2 D/libc-netbsd: [getaddrinfo]: hostname=xxxxx; servname=(null); cache_mode=(null), netid=0; mark=0 03-10 10:17:43.809 32527-5764/global.Here.Map.Service.v2 D/libc: getaddrinfo called from pid =32527 03-10 10:17:43.809 32527-5764/global.Here.Map.Service.v2 D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=xxxxx; ai_flags=4; ai_family=0 03-10 10:17:43.809 32527-5764/global.Here.Map.Service.v2 D/libc-netbsd: [getaddrinfo]: hostname=xxxxx; servname=(null); cache_mode=(null), netid=0; mark=0 03-10 10:17:43.809 32527-5764/global.Here.Map.Service.v2 D/libc: getaddrinfo called from pid =32527 03-10 10:17:43.809 32527-5764/global.Here.Map.Service.v2 D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=xxxxx; ai_flags=1024; ai_family=0 03-10 10:17:46.815 32527-5764/global.Here.Map.Service.v2 E/NetworkProtocol: NetworkProtocol::GetTask::run exception: java.net.UnknownHostException: Unable to resolve host "version.hybrid.api.here.com": Unknown error 03-10 10:17:46.815 32527-5764/global.Here.Map.Service.v2 W/System.err: java.net.UnknownHostException: Unable to resolve host "version.hybrid.api.here.com": Unknown error 03-10 10:17:46.817 32527-5764/global.Here.Map.Service.v2 W/System.err: at java.net.InetAddress.lookupHostByName(InetAddress.java:482) 03-10 10:17:46.817 32527-5764/global.Here.Map.Service.v2 W/System.err: at java.net.InetAddress.getAllByNameImpl(InetAddress.java:255) 03-10 10:17:46.817 32527-5764/global.Here.Map.Service.v2 W/System.err: at java.net.InetAddress.getAllByName(InetAddress.java:218) 03-10 10:17:46.817 32527-5764/global.Here.Map.Service.v2 W/System.err: at com.android.okhttp.HostResolver$1.getAllByName(HostResolver.java:29) 03-10 10:17:46.817 32527-5764/global.Here.Map.Service.v2 W/System.err: at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:232) 03-10 10:17:46.817 32527-5764/global.Here.Map.Service.v2 W/System.err: at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:124) 03-10 10:17:46.817 32527-5764/global.Here.Map.Service.v2 W/System.err: at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:303) 03-10 10:17:46.817 32527-5764/global.Here.Map.Service.v2 W/System.err: at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:242) 03-10 10:17:46.817 32527-5764/global.Here.Map.Service.v2 W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:397) 03-10 10:17:46.817 32527-5764/global.Here.Map.Service.v2 W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:347) 03-10 10:17:46.817 32527-5764/global.Here.Map.Service.v2 W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:515) 03-10 10:17:46.817 32527-5764/global.Here.Map.Service.v2 W/System.err: at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105) 03-10 10:17:46.818 32527-5764/global.Here.Map.Service.v2 W/System.err: at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25) 03-10 10:17:46.818 32527-5764/global.Here.Map.Service.v2 W/System.err: at com.here.hype.NetworkProtocol$GetTask.run(NetworkProtocol.java:221) 03-10 10:17:46.818 32527-5764/global.Here.Map.Service.v2 W/System.err: at java.lang.Thread.run(Thread.java:818) 03-10 10:17:46.818 32527-5764/global.Here.Map.Service.v2 W/System.err: Caused by: android.system.GaiException: android_getaddrinfo failed: GAI_ error 401 (Unknown error) 03-10 10:17:46.818 32527-5764/global.Here.Map.Service.v2 W/System.err: at libcore.io.Posix.android_getaddrinfo(Native Method) 03-10 10:17:46.818 32527-5764/global.Here.Map.Service.v2 W/System.err: at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55) 03-10 10:17:46.818 32527-5764/global.Here.Map.Service.v2 W/System.err: at java.net.InetAddress.lookupHostByName(InetAddress.java:446) 03-10 10:17:46.818 32527-5764/global.Here.Map.Service.v2 W/System.err: ... 14 more Calculate route executed 03-10 10:21:06.554 32455-12106/com.maps.plot D/NetworkSSLContextFactory: NetworkSSLContextFactory created successfully 03-10 10:21:06.554 32455-12106/com.maps.plot D/NetworkSSLContextFactory: generateSSlContext BEGIN 03-10 10:21:06.557 32455-32455/com.maps.plot I/System.out: Route calculation progress:3% 03-10 10:21:06.630 32455-12106/com.maps.plot D/NetworkSSLContextFactory: The number of files 164 found in /storage/emulated/0/.here-maps/certs/ 03-10 10:21:06.638 32455-32455/com.maps.plot I/System.out: Route calculation progress:6% 03-10 10:21:06.707 32455-32455/com.maps.plot I/System.out: Route calculation progress:9% 03-10 10:21:06.755 32455-32455/com.maps.plot I/System.out: Route calculation progress:12% 03-10 10:21:06.806 32455-32455/com.maps.plot I/System.out: Route calculation progress:15% 03-10 10:21:06.881 32455-32455/com.maps.plot I/System.out: Route calculation progress:18% 03-10 10:21:06.954 32455-32455/com.maps.plot I/System.out: Route calculation progress:21% 03-10 10:21:06.969 32455-12106/com.maps.plot D/NetworkSSLContextFactory: The number of valid certificates 164 03-10 10:21:07.001 32455-12106/com.maps.plot D/NetworkSSLContextFactory: generateSSlContext END javax.net.ssl.SSLContext@35325c17 03-10 10:21:07.002 32455-12106/com.maps.plot D/libc-netbsd: [getaddrinfo]: hostname=xxxxx; servname=(null); cache_mode=(null), netid=0; mark=0 03-10 10:21:07.002 32455-12106/com.maps.plot D/libc: getaddrinfo called from pid =32455 03-10 10:21:07.002 32455-12106/com.maps.plot D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=xxxxx; ai_flags=4; ai_family=0 03-10 10:21:07.002 32455-12106/com.maps.plot D/libc-netbsd: [getaddrinfo]: hostname=xxxxx; servname=(null); cache_mode=(null), netid=0; mark=0 03-10 10:21:07.002 32455-12106/com.maps.plot D/libc: getaddrinfo called from pid =32455 03-10 10:21:07.002 32455-12106/com.maps.plot D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=xxxxx; ai_flags=1024; ai_family=0 03-10 10:21:07.003 32455-12106/com.maps.plot D/libc: remote DNS query failed we don't need to try local DNS query result_code =401 03-10 10:21:07.003 32455-12106/com.maps.plot D/libc: dnsproxy getaddrinfo returns 401 03-10 10:21:07.003 32455-12106/com.maps.plot D/libc-netbsd: [getaddrinfo]: hostname=xxxxx; servname=(null); cache_mode=(null), netid=0; mark=0 03-10 10:21:07.003 32455-12106/com.maps.plot D/libc: getaddrinfo called from pid =32455 03-10 10:21:07.003 32455-12106/com.maps.plot D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=xxxxx; ai_flags=4; ai_family=0 03-10 10:21:07.004 32455-12106/com.maps.plot D/libc-netbsd: [getaddrinfo]: hostname=xxxxx; servname=(null); cache_mode=(null), netid=0; mark=0 03-10 10:21:07.004 32455-12106/com.maps.plot D/libc: getaddrinfo called from pid =32455 03-10 10:21:07.004 32455-12106/com.maps.plot D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=xxxxx; ai_flags=1024; ai_family=0 03-10 10:21:07.005 32455-12106/com.maps.plot E/NetworkProtocol: NetworkProtocol::GetTask::run exception: java.net.UnknownHostException: Unable to resolve host "v107-61-30-8.route.hybrid.api.here.com": Unknown error 03-10 10:21:07.005 32455-12106/com.maps.plot W/System.err: java.net.UnknownHostException: Unable to resolve host "v107-61-30-8.route.hybrid.api.here.com": Unknown error 03-10 10:21:07.005 32455-12106/com.maps.plot W/System.err: at java.net.InetAddress.lookupHostByName(InetAddress.java:482) 03-10 10:21:07.005 32455-12106/com.maps.plot W/System.err: at java.net.InetAddress.getAllByNameImpl(InetAddress.java:255) 03-10 10:21:07.005 32455-12106/com.maps.plot W/System.err: at java.net.InetAddress.getAllByName(InetAddress.java:218) 03-10 10:21:07.005 32455-12106/com.maps.plot W/System.err: at com.android.okhttp.HostResolver$1.getAllByName(HostResolver.java:29) 03-10 10:21:07.005 32455-12106/com.maps.plot W/System.err: at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:232) 03-10 10:21:07.006 32455-12106/com.maps.plot W/System.err: at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:124) 03-10 10:21:07.006 32455-12106/com.maps.plot W/System.err: at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:303) 03-10 10:21:07.006 32455-12106/com.maps.plot W/System.err: at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:242) 03-10 10:21:07.006 32455-12106/com.maps.plot W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:397) 03-10 10:21:07.006 32455-12106/com.maps.plot W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:347) 03-10 10:21:07.006 32455-12106/com.maps.plot W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:515) 03-10 10:21:07.006 32455-12106/com.maps.plot W/System.err: at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105) 03-10 10:21:07.006 32455-12106/com.maps.plot W/System.err: at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25) 03-10 10:21:07.006 32455-12106/com.maps.plot W/System.err: at com.here.hype.NetworkProtocol$GetTask.run(NetworkProtocol.java:221) 03-10 10:21:07.006 32455-12106/com.maps.plot W/System.err: at java.lang.Thread.run(Thread.java:818) 03-10 10:21:07.006 32455-12106/com.maps.plot W/System.err: Caused by: android.system.GaiException: android_getaddrinfo failed: GAI_ error 401 (Unknown error) 03-10 10:21:07.006 32455-12106/com.maps.plot W/System.err: at libcore.io.Posix.android_getaddrinfo(Native Method) 03-10 10:21:07.006 32455-12106/com.maps.plot W/System.err: at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55) 03-10 10:21:07.006 32455-12106/com.maps.plot W/System.err: at java.net.InetAddress.lookupHostByName(InetAddress.java:446) 03-10 10:21:07.006 32455-12106/com.maps.plot W/System.err: ... 14 more 03-10 10:21:07.024 32455-32455/com.maps.plot I/System.out: Route calculation progress:24% 03-10 10:21:07.101 32455-32455/com.maps.plot I/System.out: Route calculation progress:27% 03-10 10:21:07.104 32455-32455/com.maps.plot I/System.out: Route calculation failed: REQUEST_TIMEOUT 03-10 10:21:50.626 32455-32455/com.maps.plot I/System.out: Location changed 42.10214493:-87.8712617 )。

我的尝试:

.xls

我得到的错误:

# -*- coding:utf-8 -*-
require 'writeexcel'

# Create a new Excel workbook
workbook = WriteExcel.new('ruby.xls')

# Add a worksheet
worksheet = workbook.add_worksheet

eec =  [
  ['maggie', 'milly', 'molly', 'may'  ],
  [13,       14,      15,      16     ],
  ['shell',  'star',  'crab',  'stone']
  ]

worksheet.write_col('A1', \@eec)

workbook.close

使用找到here的gem文档。

任何人都可以解释为什么会出现这种语法错误,以及我如何解决它?

1 个答案:

答案 0 :(得分:2)

write_col

的调用中删除垃圾符号
- worksheet.write_col('A1', \@eec)
+ worksheet.write_col('A1', eec)