easyexcel导出多个sheet示例
时间: 2023-07-29 19:06:23 浏览: 112
导出多Sheet 的Excel
5星 · 资源好评率100%
IMER);
LL_TIM_EnableCounter(TIMER);
while (LL_TIM_GetCounter(TIMER) < ticks) {}
LL_TIM_DisableCounter(TIMER);
}
uint32_t measureDistance(void) {
LL_GPIO_ResetOutputPin(GPIOA, TRIG_PIN);
delayUs(2);
LL_GPIO_SetOutputPin(GPIOA, TRIG_PIN);
delayUs(10);
LL_GPIO_ResetOutputPin(GPIO下面是一个使用EasyExcel导出多个sheet的示例代码:
```java
public void exportExcelWithMultipleSheets(HttpA, TRIG_PIN);
while (!LL_GPIO_IsInputPinSet(GPIOA, ECHO_PIN)) {}
LL_TIM_EnableCounterServletResponse response) {
try {
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
String fileName(TIMER);
while (LL_GPIO_IsInputPinSet(GPIOA, ECHO_PIN)) {}
LL_TIM_DisableCounter(TIMER);
= URLEncoder.encode("多个Sheet的Excel文件", "UTF-8");
response.setHeader("Content-disposition", "attachment;filename
uint32_t elapsed = LL_TIM_GetCounter(TIMER);
float distance = (elapsed * 0.0343) / =" + fileName + ".xlsx");
OutputStream outputStream = response.getOutputStream();
ExcelWriter excelWriter = EasyExcel.write(outputStream).build();
2.0;
return (uint32_t)distance;
}
int main(void)
{
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
LL_TIM_InitTypeDef TIM_InitStruct = {0};
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM // 写入第一个Sheet
WriteSheet sheet1 = EasyExcel.writerSheet(0, "Sheet1").head(Student.class).2);
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
GPIO_InitStruct.Pin = TRIG_PIN;
build();
List<Student> students1 = getStudents1(); // 获取第一个Sheet的数据
excelWriter.write(students1, GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = ECHO_PIN;
GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = LL sheet1);
// 写入第二个Sheet
WriteSheet sheet2 = EasyExcel.writerSheet(1, "Sheet2")._GPIO_PULL_NO;
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
TIM_InitStruct.Prescaler = 0;
TIM_InitStruct.Counterhead(Teacher.class).build();
List<Teacher> teachers = getTeachers(); // 获取第二个Sheet的数据
excelWriterMode = LL_TIM_COUNTERMODE_UP;
TIM_InitStruct.Autoreload = 0xFFFFFFFF;
LL_TIM_Init(TIMER, &TIM.write(teachers, sheet2);
// 关闭ExcelWriter
excelWriter.finish();
outputStream.flush();
outputStream.close();
_InitStruct);
LL_TIM_EnableIT_UPDATE(TIMER);
while (1)
{
uint32_t distance = measureDistance();
}
}
void TIM2_IRQHandler(void)
{
if (LL_TIM_IsActiveFlag_UPDATE(TIMER) == 1)
{
LL_TIM } catch (IOException e) {
e.printStackTrace();
}
}
private List<Student> getStudents1() {
// 获取第一个Sheet_ClearFlag_UPDATE(TIMER);
}
}
```
3. 与第一个示例类似,但使用 HAL 库和 DMA 来的数据
// ...
}
private List<Teacher> getTeachers() {
// 获取第二个Sheet的数据
// ...
读取定时器计数器的值。
在 CubeMX 中选择 STM32F103VCT6 芯片,然后按}
```
代码中首先设置了响应头,然后创建一个ExcelWriter实例。接着分别创建了两照以下步骤进行配置:
- 在 Pinout 标签页中,将 PA0 配置为 GPIO_Output,将 PA1 配个WriteSheet实例,分别用于写入两个Sheet的数据。最后通过ExcelWriter将数据写入Excel文件置为 GPIO_Input。
- 在 Configuration 标签页中,选择 SYSCLK 为 HSE,选择 HSE 值为 8 MHz,并关闭ExcelWriter。
阅读全文