Skip to content

Commit

Permalink
Merge pull request #246 from viest/dev
Browse files Browse the repository at this point in the history
windows full function support
  • Loading branch information
viest authored Apr 12, 2020
2 parents 98188f1 + 603f037 commit 2de95de
Show file tree
Hide file tree
Showing 17 changed files with 3,909 additions and 240 deletions.
427 changes: 223 additions & 204 deletions .appveyor.yml

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@
[submodule "library/libexpat"]
path = library/libexpat
url = https://github.com/libexpat/libexpat.git
branch = R_2_2_7
[submodule "library/libxlsxio"]
path = library/libxlsxio
url = https://github.com/brechtsanders/xlsxio.git
branch = 0.2.26
branch = R_2_2_7
76 changes: 66 additions & 10 deletions config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,77 @@ ARG_WITH("xlswriter", "xlswriter support", "no");

if (PHP_XLSWRITER != "no") {

if (CHECK_LIB("xlsxwriter.lib;xlsxwriter_a.lib", "xlswriter", PHP_XLSWRITER) &&
CHECK_HEADER_ADD_INCLUDE("xlsxwriter.h", "CFLAGS_XLSWRITER", PHP_PHP_BUILD + "\\include;" + PHP_XLSWRITER) &&
CHECK_HEADER_ADD_INCLUDE("xlsxwriter/format.h", "CFLAGS_XLSWRITER", PHP_PHP_BUILD + "\\include;" + PHP_XLSWRITER) &&
CHECK_HEADER_ADD_INCLUDE("xlsxwriter/packager.h", "CFLAGS_XLSWRITER", PHP_PHP_BUILD + "\\include;" + PHP_XLSWRITER) &&
CHECK_HEADER_ADD_INCLUDE("xlswriter.h", "CFLAGS_XLSWRITER", configure_module_dirname + "\\include;" + PHP_EXTRA_INCLUDES)) {

if (
CHECK_HEADER_ADD_INCLUDE("minizip/zip.h", "CFLAGS_XLSWRITER", configure_module_dirname + "\\library\\libxlsxwriter\\third_party;" + PHP_EXTRA_INCLUDES) &&
CHECK_HEADER_ADD_INCLUDE("xlsxwriter.h", "CFLAGS_XLSWRITER", configure_module_dirname + "\\library\\libxlsxwriter\\include;" + PHP_EXTRA_INCLUDES) &&
CHECK_HEADER_ADD_INCLUDE("expat.h", "CFLAGS_XLSWRITER", configure_module_dirname + "\\library\\libexpat\\expat\\lib;" + PHP_EXTRA_INCLUDES) &&
CHECK_HEADER_ADD_INCLUDE("xlsxio_read.h", "CFLAGS_XLSWRITER", configure_module_dirname + "\\library\\libxlsxio\\include;" + PHP_EXTRA_INCLUDES) &&
CHECK_HEADER_ADD_INCLUDE("xlswriter.h", "CFLAGS_XLSWRITER", configure_module_dirname + "\\include;" + PHP_EXTRA_INCLUDES)
) {
EXTENSION("xlswriter", "xlswriter.c")

ADD_FLAG("CFLAGS_XLSWRITER", ' /I "' + configure_module_dirname + '" ');
ADD_FLAG("CFLAGS_XLSWRITER", ' /D ENABLE_READER /D USE_SYSTEM_MINIZIP /D USE_MINIZIP /I "' + configure_module_dirname + '" ');

AC_DEFINE("HAVE_LXW_VERSION", 1, "lxw_version available in 0.7.7");

ADD_SOURCES(configure_module_dirname + "\\kernel", "common.c resource.c exception.c excel.c write.c format.c chart.c", "xlswriter");
ADD_SOURCES(configure_module_dirname + "\\kernel", "\
exception.c \
resource.c \
common.c \
excel.c \
write.c \
format.c \
chart.c \
read.c \
csv.c \
", "xlswriter");

ADD_SOURCES(configure_module_dirname + "\\library\\libxlsxwriter\\third_party\\minizip", "\
ioapi.c \
iowin32.c \
mztools.c \
unzip.c \
zip.c \
", "xlswriter");

ADD_SOURCES(configure_module_dirname + "\\library\\libxlsxwriter\\third_party\\tmpfileplus", "\
tmpfileplus.c \
", "xlswriter");

ADD_SOURCES(configure_module_dirname + "\\library\\libxlsxwriter\\src", "\
app.c \
chart.c \
content_types.c \
core.c \
custom.c \
drawing.c \
format.c \
hash_table.c \
packager.c \
relationships.c \
shared_strings.c \
styles.c \
theme.c \
utility.c \
workbook.c \
worksheet.c \
xmlwriter.c \
", "xlswriter", "libxlsxwriter");

ADD_SOURCES(configure_module_dirname + "\\library\\libexpat\\expat\\lib", "\
loadlibrary.c \
xmlparse.c \
xmlrole.c \
xmltok.c \
xmltok_impl.c \
xmltok_ns.c \
", "xlswriter");

ADD_SOURCES(configure_module_dirname + "\\library\\libxlsxio\\lib", "\
xlsxio_read.c \
xlsxio_read_sharedstrings.c \
", "xlswriter");
} else {
WARNING("xlswriter not enabled, xlsxwriter.lib or headers not found");
}

}
}
22 changes: 16 additions & 6 deletions kernel/excel.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "xlswriter.h"
#include "ext/date/php_date.h"
#include "ext/standard/php_filestat.h"

zend_class_entry *vtiful_xls_ce;

Expand Down Expand Up @@ -273,7 +274,7 @@ PHP_METHOD(vtiful_xls, __construct)
PHP_METHOD(vtiful_xls, fileName)
{
char *sheet_name = NULL;
zval file_path, *dir_path = NULL;
zval file_path, dir_exists, *dir_path = NULL;
zend_string *zs_file_name = NULL, *zs_sheet_name = NULL;

ZEND_PARSE_PARAMETERS_START(1, 2)
Expand All @@ -282,10 +283,17 @@ PHP_METHOD(vtiful_xls, fileName)
Z_PARAM_STR(zs_sheet_name)
ZEND_PARSE_PARAMETERS_END();

ZVAL_NULL(&dir_exists);
ZVAL_COPY(return_value, getThis());

GET_CONFIG_PATH(dir_path, vtiful_xls_ce, return_value);

php_stat(ZSTR_VAL(Z_STR_P(dir_path)), strlen(ZSTR_VAL(Z_STR_P(dir_path))), FS_IS_DIR, &dir_exists);

if (Z_TYPE(dir_exists) == IS_FALSE) {
zend_throw_exception(vtiful_exception_ce, "Configure 'path' directory does not exist", 121);
}

xls_object *obj = Z_XLS_P(getThis());

if(obj->write_ptr.workbook == NULL) {
Expand All @@ -302,6 +310,8 @@ PHP_METHOD(vtiful_xls, fileName)

zval_ptr_dtor(&file_path);
}

zval_ptr_dtor(&dir_exists);
}
/* }}} */

Expand Down Expand Up @@ -913,15 +923,15 @@ PHP_METHOD(vtiful_xls, stringFromColumnIndex)
PHP_METHOD(vtiful_xls, gridline)
{
zend_long option = LXW_SHOW_ALL_GRIDLINES;

ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_LONG(option)
ZEND_PARSE_PARAMETERS_END();

ZVAL_COPY(return_value, getThis());

xls_object* obj = Z_XLS_P(getThis());

gridlines(&obj->write_ptr, option);
}
/* }}} */
Expand Down Expand Up @@ -1236,7 +1246,7 @@ zend_function_entry xls_methods[] = {

PHP_ME(vtiful_xls, zoom, xls_sheet_zoom_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(vtiful_xls, gridline, xls_sheet_gridline_arginfo, ZEND_ACC_PUBLIC)

PHP_ME(vtiful_xls, columnIndexFromString, xls_index_to_string, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(vtiful_xls, stringFromColumnIndex, xls_string_to_index, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)

Expand Down Expand Up @@ -1285,7 +1295,7 @@ VTIFUL_STARTUP_FUNCTION(excel) {
REGISTER_CLASS_CONST_LONG(vtiful_xls_ce, "GRIDLINES_SHOW_ALL", LXW_SHOW_ALL_GRIDLINES)
REGISTER_CLASS_CONST_LONG(vtiful_xls_ce, "GRIDLINES_SHOW_PRINT", LXW_SHOW_PRINT_GRIDLINES)
REGISTER_CLASS_CONST_LONG(vtiful_xls_ce, "GRIDLINES_SHOW_SCREEN", LXW_SHOW_SCREEN_GRIDLINES)

REGISTER_CLASS_CONST_LONG(vtiful_xls_ce, V_XLS_CONST_READ_TYPE_INT, READ_TYPE_INT);
REGISTER_CLASS_CONST_LONG(vtiful_xls_ce, V_XLS_CONST_READ_TYPE_DOUBLE, READ_TYPE_DOUBLE);
REGISTER_CLASS_CONST_LONG(vtiful_xls_ce, V_XLS_CONST_READ_TYPE_STRING, READ_TYPE_STRING);
Expand Down
6 changes: 4 additions & 2 deletions kernel/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@

/* {{{ */
xlsxioreader file_open(const char *directory, const char *file_name) {
char path[strlen(directory) + strlen(file_name) + 2];
char *path = (char *)emalloc(strlen(directory) + strlen(file_name) + 2);
xlsxioreader file;

lxw_strcpy(path, directory);
strcpy(path, directory);
strcat(path, "/");
strcat(path, file_name);

if ((file = xlsxioread_open(path)) == NULL) {
efree(path);
zend_throw_exception(vtiful_exception_ce, "Failed to open file", 100);
return NULL;
}

efree(path);
return file;
}
/* }}} */
Expand Down
1 change: 0 additions & 1 deletion library/libxlsxio
Submodule libxlsxio deleted from b9399e
19 changes: 19 additions & 0 deletions library/libxlsxio/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (C) 2016 Brecht Sanders All Rights Reserved

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Loading

0 comments on commit 2de95de

Please sign in to comment.