我想创建然后将2个文件添加到与附件相同的文件中。 我怎样才能做到这一点?请在下面找到我到目前为止尝试的内容。 Excel文件来自资源/文件,TXT文件只是在文档保存过程中创建的。
importPackage(org.apache.poi.ss.usermodel);
var resourcePath = "/SampleExcelFile.xlsx";
var bantfile = java.lang.System.getProperty("java.io.tmpdir");
var srtEk = "FileName1";
var excelName = srtEk + ".xlsx";
var textFileName = srtEk + +".txt";
var excelFilePath = bantfile+"\\"+ excelName;
var ledesFilePath = bantfile+"\\"+ textFileName;
var inp = facesContext.getExternalContext().getResourceAsStream(resourcePath);
var wb = WorkbookFactory.create(inp);
var sheet = wb.getSheetAt(0);
var row = sheet.getRow(2);
if (row == null)
{
row = sheet.createRow(2);
}
var cell = row.getCell(0);
if (cell == null)
{
cell = row.createCell(0);
}
cell.setCellType(Cell.CELL_TYPE_STRING);
cell.setCellValue(tempFilePath);
var fileOut = new java.io.FileOutputStream(excelFilePath);
wb.write(fileOut);
fileOut.close();
var fileOut = new java.io.FileOutputStream(ledesFilePath);
wb.write(fileOut);
fileOut.close();
var doc = database.createDocument();
doc.replaceItemValue("Form", "frmTest");
var rtitem = doc.createRichTextItem("Body");
rtitem.embedObject(lotus.domino.local.EmbeddedObject.EMBED_ATTACHMENT, null, excelFilePath , null);
doc.save(true, false);
答案 0 :(得分:3)
您可以根据需要为RichText字段添加尽可能多的附件 只需在代码中添加另一个embedObject行:
rtitem.embedObject(lotus.domino.local.EmbeddedObject.EMBED_ATTACHMENT, null, ledesFilePath, null);