-
-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Libxlsxwriter API refactoring in progress - Porters take note. #252
Comments
@Alexhuszagh @RaFaeL-NN @sjmulder @Paxa@ @FTrautwein @gekola @HalfWayMan @Rolltrax @ropensci @yoeljacobsen @viest @fterrag Please note this refactoring to libxlsxwriter which may affect your ports/wrappers. |
Refactored the chart fonts struct to document or remove hidden fields. See #252
Documented optional file creation datetime in lxw_doc_properties. See #252
Made the deprecation of new_workbook() funtion more explicit and removed instances from the examples and test code. The workbook_new() function should be used instead. See #252
Refactored the data validation struct to remove hidden fields. See #252
Refactored the worksheet protection struct to remove hidden fields. See #252
Refactored the chart pattern struct to remove hidden fields. See #252
I've made a series of changes to fix the internal/external struct issues and document any unused (for now) fields. Hopefully this will make the ABI/API more stable in the future and less brittle for people instantiating structs to pass to the API. I merge this up to master later and will release it in approximately the next day. If anyone sees any issues let me know. |
I get "error: wrong number of arguments specified for `deprecated' attribute" under MinGW |
Also, code for copying of user_props->created to doc_props does not exists in workbook_set_properties. If it's documented now, I think it must be or not? |
I don't see that in my MinGW environment. How are you compiling it?
It is documented in the |
I don't know how to answer on this. I type "make" in MSYS under Windows |
I followed the steps shown in the libxlsxwriter user guide for installing on Windows using Mingw-w64 and MSYS2 and when I type
I've added an explanation of the http://libxlsxwriter.github.io/workbook_8h.html#aa814fd7f8d2c3ce86a7aa5d5ed127000 |
I still can't see any code for this in workbook_set_properties in workbook.c at master. How it works? Is there an example? |
Sorry. I understand now. I had omitted copying the user value. I've fixed it on master. Here is a working example: #include "xlsxwriter.h"
int main() {
lxw_workbook *workbook = workbook_new("doc_properties.xlsx");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
struct tm tmp_tm;
tmp_tm.tm_year = 119;
tmp_tm.tm_mon = 3;
tmp_tm.tm_mday = 17;
tmp_tm.tm_hour = 19;
tmp_tm.tm_min = 45;
tmp_tm.tm_sec = 15;
tmp_tm.tm_isdst = -1;
/* Create a properties structure and set some of the fields. */
lxw_doc_properties properties = {
.title = "This is an example spreadsheet",
.subject = "With document properties",
.author = "John McNamara",
.manager = "Dr. Heinz Doofenshmirtz",
.company = "of Wolves",
.category = "Example spreadsheets",
.keywords = "Sample, Example, Properties",
.comments = "Created with libxlsxwriter",
.status = "Quo",
.created = timegm(&tmp_tm),
};
/* Set the properties in the workbook. */
workbook_set_properties(workbook, &properties);
/* Add some text to the file. */
worksheet_set_column(worksheet, 0, 0, 50, NULL);
worksheet_write_string(worksheet, 0, 0,
"Select 'Workbook Properties' to see properties." , NULL);
workbook_close(workbook);
return 0;
} |
Merged upstream in version 0.8.8. |
Libxlsxwriter uses two kinds of structs as API parameters:
The second type are always copied by the library and freed afterwards, i.e., the library never touches the public user data. However, some of these struct types are also used internally and some of the fields/members for metadata are shared with the external structs. This can cause issues where these fields aren't initialised by the user or just cause general confusion when inspected by the user.
This also make the API/ABI quite fragile since additional fields are often added to internal structs.
For the next version (0.8.8) of the library I'm going to rework the APIs so that external facing structs only contain documented fields and so that different structs are used internally if they require any additional metadata.
If you are porting or wrapping libxlsxwriter then this change will probably cause you some rework as well (although if you are just following the external documented APIs you will probably be okay).
Hopefully this will be a one-off overhead.
You can try out the changes from this rework on the api_refactor branch.
The text was updated successfully, but these errors were encountered: