我正在尝试使用this库在xlsx文件中写入图像,因为该文档建议了在xlsx文件中写入图像的方法,我也遵循同样的方法,但是无法成功。
下面是我用来写图像的代码段
第一种方法
Worksheet.add(image, inCellReferenced: "A2", withOffset: CGPoint(x:15, y:10), size: (image?.size)! , preserveTransparency: true)
第二种方法
let drawing: BRAWorksheetDrawing = Worksheet.add(image, betweenCellsReferenced: "C2", and: "D2", with: UIEdgeInsets.zero, preserveTransparency: false)
drawing.insets = UIEdgeInsetsMake(0.0, 0.0, 0.5, 0.5)
使用这两种方法,我都无法将图像写入xlsx文件,任何帮助都将是非常有用的!!
答案 0 :(得分:0)
尝试一下,这对我有帮助
let data = UIImageJPEGRepresentation(UIImage, 0.5)
let image = UIImage(data: data!)
let drawing: BRAWorksheetDrawing = firstWorksheet.add(image, betweenCellsReferenced: startCell, and: endCell, with: UIEdgeInsets.zero, preserveTransparency: true)
drawing.shouldKeepAspectRatio = false