#include <stdio.
h>
#include <zip.h>
int main() {
struct zip *archive;
struct zip_source *source;
int err = 0;
// Create a new .ods ZIP file
archive = zip_open("[Link]", ZIP_CREATE | ZIP_TRUNCATE, &err);
if (!archive) {
fprintf(stderr, "Failed to create .ods file.\n");
return 1;
}
// Add required "mimetype" file
const char *mimetype = "application/[Link]";
source = zip_source_buffer(archive, mimetype, strlen(mimetype), 0);
zip_file_add(archive, "mimetype", source, ZIP_FL_ENC_UTF_8);
// Add a very basic [Link]
const char *content_xml =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<office:document-content "
"xmlns:office=\"urn:oasis:names:tc:opendocument:xmlns:office:1.0\" "
"xmlns:table=\"urn:oasis:names:tc:opendocument:xmlns:table:1.0\" "
"xmlns:text=\"urn:oasis:names:tc:opendocument:xmlns:text:1.0\">"
"<office:body><office:spreadsheet>"
"<table:table table:name=\"Sheet1\">"
"<table:table-row>"
"<table:table-cell><text:p>Name</text:p></table:table-cell>"
"<table:table-cell><text:p>Age</text:p></table:table-cell>"
"</table:table-row>"
"<table:table-row>"
"<table:table-cell><text:p>Alice</text:p></table:table-cell>"
"<table:table-cell><text:p>25</text:p></table:table-cell>"
"</table:table-row>"
"</table:table>"
"</office:spreadsheet></office:body></office:document-content>";
source = zip_source_buffer(archive, content_xml, strlen(content_xml), 0);
zip_file_add(archive, "[Link]", source, ZIP_FL_ENC_UTF_8);
// Close the archive
zip_close(archive);
printf("ODS file '[Link]' created successfully!\n");
return 0;
}