将Excel文件和.TXT文件添加到XPages中的同一字段中
我想创建,然后添加2个文件到同一个文件作为附件。 我该怎么做?请在下面找到我迄今为止尝试的内容。 Excel文件来自资源/文件,TXT文件仅在文档保存过程中创建将Excel文件和.TXT文件添加到XPages中的同一字段中,xpages,Xpages,我想创建,然后添加2个文件到同一个文件作为附件。 我该怎么做?请在下面找到我迄今为止尝试的内容。 Excel文件来自资源/文件,TXT文件仅在文档保存过程中创建 importPackage(org.apache.poi.ss.usermodel); var resourcePath = "/SampleExcelFile.xlsx"; var bantfile = java.lang.System.getProperty("java.io.tmpdir"); var srtEk = "Fil
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);
您可以向RichText字段添加任意数量的附件。
只需在代码中添加另一个EmbeddeObject行:
rtitem.embedObject(lotus.domino.local.EmbeddedObject.EMBED_ATTACHMENT, null, ledesFilePath, null);