Answer the question
In order to leave comments, you need to log in
Need an example of working with GSF to create MS Structured Storage under Linux. Where to find?
I need an example for the GSF library ( https://developer.gnome.org/gsf/1.14
) how to write an MS Structured Storage format file under Linux (Raspbian) with the help of it in order to subsequently read it from under MS Windows using standard MS Windows tools . I didn’t find any documentation describing this process more or less understandably, but I found a program in which this library is used for the same purposes: https://github.com/GNOME/gnumeric . I looked at how they do it and made it like the same for myself:
#include <iostream>
extern "C" {
#include <gsf/gsf.h>
#include<glib-object.h>
}
int main()
{
gsf_init();
const char * out_file_name = "storage.bin";
GError *err;
FILE *file = fopen(out_file_name, "wr");
if (!file) {
std::cout << "file open fail" << std::endl;
exit(0);
}
GsfOutput *output = gsf_output_stdio_new_FILE (out_file_name, file, false);
GsfOutfile *output_file_ole2 = gsf_outfile_msole_new(output);
GsfOutput *output2 = gsf_outfile_new_child(output_file_ole2, "5555tteesstt", false);
int ret;
GsfDocMetaData *docMetaData = gsf_doc_meta_data_new();
GValue x = G_VALUE_INIT;
g_value_init(&x, G_TYPE_STRING);
g_value_set_string(&x, "Ttteeesssttt");
gsf_doc_meta_data_insert(docMetaData, "zzzzz", &x);
gsf_doc_meta_dump(docMetaData);
ret = gsf_doc_meta_data_write_to_msole(docMetaData, output2, true);
std::cout << "gsf_doc_meta_data_write_to_msole ret=" << ret << std::endl;
ret = gsf_output_close(output2);
g_object_unref(output2);
std::cout << "ret=" << ret << std::endl;
ret = gsf_output_close(output);
g_object_unref(output);
std::cout << "ret=" << ret << std::endl;
return 0;
}
Answer the question
In order to leave comments, you need to log in
I figured it out, here is an example of code that writes a file in MS Structured Storage format:
#include <iostream>
extern "C" {
#include <gsf/gsf.h>
#include<glib-object.h>
}
int main()
{
gsf_init();
const char *out_file_name = "storage.bin";
FILE *file = fopen(out_file_name, "wr");
if (!file) {
std::cout << "file open fail" << std::endl;
exit(0);
}
GsfOutput *output = gsf_output_stdio_new_FILE(out_file_name, file, true);
GsfOutfile *output_file_ole2 = gsf_outfile_msole_new(output);
GsfOutput *output2 = gsf_outfile_new_child(output_file_ole2, "5555tteesstt", false);
gsf_output_puts(output2, "The quick brown fox is afraid of the cats.\n");
ret = gsf_output_close(output2);
g_object_unref(G_OBJECT(output2));
gsf_output_close(GSF_OUTPUT(output_file_ole2));
g_object_unref(G_OBJECT(output_file_ole2));
ret = gsf_output_close(output);
g_object_unref(G_OBJECT(output));
gsf_shutdown();
return 0;
}
I'm not sure if this is exactly what you need, but look at https://poi.apache.org/
True, this is Java, but at least I prepared excel documents on it and not only.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question