package com.bs.mes.schedule.api;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;

import java.io.FileOutputStream;
import java.io.IOException;

public class ApiExcetlTest {


    @Test
    public void test2() {
        // 创建一个新的工作簿
        Workbook workbook = new XSSFWorkbook();
        // 创建一个工作表
        Sheet sheet = workbook.createSheet("ExampleSheet");

        // 创建行（0基索引）
        Row row = sheet.createRow(0);

        // 创建单元格并设置值
        Cell cell = row.createCell(0);
        cell.setCellValue("服务启用");
        cell = row.createCell(1);
        cell.setCellValue("接口服务描述");
        cell = row.createCell(2);
        cell.setCellValue("接口地址");
        cell = row.createCell(3);
        cell.setCellValue("api地址");

        // 写入到文件
        try (FileOutputStream outputStream = new FileOutputStream("C:\\Users\\1\\Desktop\\example.xlsx")) {
            workbook.write(outputStream);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // 清理资源
            try {
                workbook.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}