在oracle创建一个blob转base64的函数
CREATE OR REPLACE Function BASE64ENCODE(Blob_In In Blob) Return clob Is
I_CLOB CLOB;
I_STEP PLS_INTEGER := 12000;
Begin
If Dbms_Lob.Getlength(Blob_In) Is Null THEN
Return '';
End if;
For I In 0 .. TRUNC((DBMS_LOB.GETLENGTH(Blob_In) - 1) / I_STEP) LOOP
I_CLOB := I_CLOB ||
UTL_RAW.CAST_TO_VARCHAR2(
UTL_ENCODE.BASE64_ENCODE(DBMS_LOB.substr(Blob_In,
I_STEP,
I * I_STEP + 1 ))
);
END LOOP;
Return I_CLOB;
END;
查询图片是调用该函数,如:
select BASE64ENCODE(img) path from tableName;
在A1单元格输出path列,B1单元格引用A1单元格,如:
"<img style = 'width:65%;height:60%;' src='data:image/png;base64,"+A1+"'>"
单元格B1用html格式显示,图片布局用适应