功能: 服务端生成完整报告并保护单任务
- 使用 libxlsxwriter 常量内存导出 Excel\n- 增加全局任务占用提示与原始数据持久化\n- 保留运行时任务数据并更新接口文档
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* A simple program to write some data to an Excel file using the
|
||||
* libxlsxwriter library.
|
||||
*
|
||||
* This program is shown, with explanations, in Tutorial 1 of the
|
||||
* libxlsxwriter documentation.
|
||||
*
|
||||
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org
|
||||
*
|
||||
*/
|
||||
|
||||
#include "xlsxwriter.h"
|
||||
|
||||
/* Some data we want to write to the worksheet. */
|
||||
struct expense {
|
||||
char item[32];
|
||||
int cost;
|
||||
};
|
||||
|
||||
struct expense expenses[] = {
|
||||
{"Rent", 1000},
|
||||
{"Gas", 100},
|
||||
{"Food", 300},
|
||||
{"Gym", 50},
|
||||
};
|
||||
|
||||
|
||||
int main() {
|
||||
|
||||
/* Create a workbook and add a worksheet. */
|
||||
lxw_workbook *workbook = workbook_new("tutorial01.xlsx");
|
||||
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
|
||||
|
||||
/* Start from the first cell. Rows and columns are zero indexed. */
|
||||
int row = 0;
|
||||
int col = 0;
|
||||
|
||||
/* Iterate over the data and write it out element by element. */
|
||||
for (row = 0; row < 4; row++) {
|
||||
worksheet_write_string(worksheet, row, col, expenses[row].item, NULL);
|
||||
worksheet_write_number(worksheet, row, col + 1, expenses[row].cost, NULL);
|
||||
}
|
||||
|
||||
/* Write a total using a formula. */
|
||||
worksheet_write_string (worksheet, row, col, "Total", NULL);
|
||||
worksheet_write_formula(worksheet, row, col + 1, "=SUM(B1:B4)", NULL);
|
||||
|
||||
/* Save the workbook and free any allocated memory. */
|
||||
return workbook_close(workbook);
|
||||
}
|
||||
Reference in New Issue
Block a user