gpt4 book ai didi

java - 需要按预期将长字符串值发送到 Excel

转载 作者:行者123 更新时间:2023-12-02 09:17:02 26 4
gpt4 key购买 nike

我得到的字符串值是(控制台 View )this我的输出是(excel)here我需要将输出视为 this在Excel中。有什么解决办法吗?

关键字

@Keyword
public void demoKey(String name) throws IOException{

FileInputStream fis = new FileInputStream("C:\\Users\\\\Decypha data files\\Demo1.xlsx");
XSSFWorkbook workbook = new XSSFWorkbook(fis);

XSSFSheet sheet = workbook.getSheet("Sheet1");
int rowCount = sheet.getLastRowNum()-sheet.getFirstRowNum();
Row row = sheet.createRow(rowCount+1);
Cell cell = row.createCell(0);
cell.setCellType(cell.CELL_TYPE_STRING);
cell.setCellValue(name);
FileOutputStream fos = new FileOutputStream("C:\\Users\\\\Decypha data files\\Demo1.xlsx");
workbook.write(fos);
fos.close();

测试用例

String str = arrlist.toString();
str = str.replaceAll("[\\[\\]]", "");
System.out.println(str);
String listString = String.join(", ", str);
String[] arrOfStr = listString.split("\\|");
CustomKeywords.'WriteExcel.demoKey'(listString)
for (String a : arrOfStr)
System.out.println(a);

最佳答案

在 for 循环内调用 demoKey 方法,如下所示。

for(String a:arrOfStr)
{
System.out.println(a);
CustomKeywords.`WriteExcel.demoKey'(a);
}

关于java - 需要按预期将长字符串值发送到 Excel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58913354/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com