问答详情
源自:3-7 xlwt写入Excel

图片只能用bmp图片吗

图片只能用bmp图片吗


提问者:墨烟溪 2020-08-03 09:01

个回答

  • 离岛
    2020-08-03 09:26:42

    insert_bitmap()仅适用于bmp格式,xlsxwriter不仅支持bmp,而且还支持jpeg和png文件,通过worksheet.insert_image

  • 慕粉0000166267
    2021-02-04 14:49:16

    Traceback (most recent call last):

      File "E:/Embedded programming/Python/excel/writeExcel.py", line 19, in <module>

        wsimage.insert_bitmap("无标题.jpg",0,0)

      File "D:\Program Files\Python387\lib\site-packages\xlwt\Worksheet.py", line 1122, in insert_bitmap

        bmp = Bitmap.ImDataBmpRecord(filename)

      File "D:\Program Files\Python387\lib\site-packages\xlwt\Bitmap.py", line 273, in __init__

        self.width, self.height, self.size, data = _process_bitmap(filename)

      File "D:\Program Files\Python387\lib\site-packages\xlwt\Bitmap.py", line 198, in _process_bitmap

        return _process_bitmap_data(data)

      File "D:\Program Files\Python387\lib\site-packages\xlwt\Bitmap.py", line 206, in _process_bitmap_data

        raise Exception("bitmap doesn't appear to to be a valid bitmap image.")

    Exception: bitmap doesn't appear to to be a valid bitmap image.

    我添加png和JPG格式的,显示这个报错