package main
import (
"C"
"github.com/360EntSecGroup-Skylar/excelize"
)
func background(excelname, sheetname, image *C.char) *C.char {
excelname_go := C.GoString(excelname)
sheetname_go := C.GoString(sheetname)
image_go := C.GoString(image)
xlsx, err := excelize.OpenFile(excelname_go)
if err != nil {
panic(err)
}
xlsx.SetSheetBackground(sheetname_go, image_go)
err = xlsx.SaveAs(excelname_go)
if err != nil {
panic(err)
}
return C.CString("success")
}
func main() {}
import ctypes
from ctypes import cdll
def set_background():
name = b'/Users/myyou/work/background.xlsx'
background = cdll.LoadLibrary('/Users/myyou/work/excel.so').background
background.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p]
background.restype = ctypes.c_char_p
background(name, b'Sheet1', b'/Users/myyou/work/ntim.jpg')
return 'ok'
Traceback (most recent call last):
File "/Users/myyou/work/pythonenv/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2910, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-3-24964e319282>", line 1, in <module>
set_background()
File "/Users/myyou/work/test.py", line 275, in
background = cdll.LoadLibrary('/Users/kamui/work/excel.so').background
File "/Users/myyou/.pyenv/versions/3.6.2/lib/python3.6/ctypes/__init__.py", line 361, in __getattr__
func = self.__getitem__(name)
File "/Users/myyou/.pyenv/versions/3.6.2/lib/python3.6/ctypes/__init__.py", line 366, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(0x7fe2a7d4ea30, background): symbol not found
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.