Permalink
Browse files

ExcelSheet methods setHidden()/isHidden()

  • Loading branch information...
1 parent 57d5b6b commit 4ad802d90c5f595a284b448b3c469d1e81873ffb @iliaal committed Oct 12, 2011
Showing with 88 additions and 1 deletion.
  1. +7 −0 ChangeLog
  2. +53 −1 excel.c
  3. +28 −0 tests/068.phpt
View
@@ -1,3 +1,10 @@
+[2011-10-12] - Version 0.9.6
+ * Added new methods (requires LibXL 3.2.3+):
+ - ExcelSheet::isHidden() that whether sheet is hidden.
+ - ExcelSheet::setHidden(bool flag) that hides/unhides the sheet.
+ * Allow compilation against LibXL 3.2.3/3.2.2
+ * Added a work-around for image index bug inside LibXL 3.2.2
+
[2011-08-03] - Version 0.9.1
* Added new methods (requires LibXL 3.2.0+):
- ExcelSheet::setPrintFit(int wPages, int hPages) that fits sheet width and sheet height to wPages and hPages respectively
View
54 excel.c
@@ -61,7 +61,7 @@ enum libXLPictureType {PICTURETYPE_PNG, PICTURETYPE_JPEG, PICTURETYPE_WMF, PICTU
#define PHP_EXCEL_FORMULA 2
#define PHP_EXCEL_NUMERIC_STRING 3
-#define PHP_EXCEL_VERSION "0.9.5"
+#define PHP_EXCEL_VERSION "0.9.6"
#ifdef COMPILE_DL_EXCEL
ZEND_GET_MODULE(excel)
@@ -2910,6 +2910,43 @@ EXCEL_METHOD(Sheet, setDisplayGridlines)
}
/* }}} */
+#if LIBXL_VERSION >= 0x03020300
+/* {{{ proto bool ExcelSheet::setHidden(bool value)
+ Hides/unhides the sheet. */
+EXCEL_METHOD(Sheet, setHidden)
+{
+ SheetHandle sheet;
+ zval *object = getThis();
+ zend_bool val;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &val) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ SHEET_FROM_OBJECT(sheet, object);
+
+ RETURN_BOOL(xlSheetSetHidden(sheet, val));
+}
+/* }}} */
+
+/* {{{ proto bool ExcelSheet::isHidden()
+ Returns whether sheet is hidden. */
+EXCEL_METHOD(Sheet, isHidden)
+{
+ SheetHandle sheet;
+ zval *object = getThis();
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ SHEET_FROM_OBJECT(sheet, object);
+
+ RETURN_BOOL(xlSheetHidden(sheet));
+}
+/* }}} */
+#endif
+
/* {{{ proto void ExcelSheet::setPrintGridlines(bool value)
Sets gridlines for printing */
EXCEL_METHOD(Sheet, setPrintGridlines)
@@ -4398,6 +4435,17 @@ PHP_EXCEL_ARGINFO
ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_zoom, 0, 0, 0)
ZEND_END_ARG_INFO()
+#if LIBXL_VERSION >= 0x03020300
+PHP_EXCEL_ARGINFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_isHidden, 0, 0, 0)
+ZEND_END_ARG_INFO()
+
+PHP_EXCEL_ARGINFO
+ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setHidden, 0, 0, 1)
+ ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO()
+#endif
+
PHP_EXCEL_ARGINFO
ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_zoomPrint, 0, 0, 0)
ZEND_END_ARG_INFO()
@@ -4786,6 +4834,10 @@ zend_function_entry excel_funcs_sheet[] = {
EXCEL_ME(Sheet, getNumPictures, arginfo_Sheet_getNumPictures, 0)
EXCEL_ME(Sheet, getPictureInfo, arginfo_Sheet_getPictureInfo, 0)
#endif
+#if LIBXL_VERSION >= 0x03020300
+ EXCEL_ME(Sheet, setHidden, arginfo_Sheet_setHidden, 0)
+ EXCEL_ME(Sheet, isHidden, arginfo_Sheet_isHidden, 0)
+#endif
{NULL, NULL, NULL}
};
View
@@ -0,0 +1,28 @@
+--TEST--
+Sheet::isHidden() / Sheet::setHidden()
+--SKIPIF--
+<?php if (!extension_loaded("excel") || !in_array('isHidden', get_class_methods('ExcelSheet'))) print "skip"; ?>
+--FILE--
+<?php
+ $x = new ExcelBook();
+ $s = $x->addSheet("Sheet 1");
+ $s2 = $x->addSheet("Sheet 2");
+ var_dump(
+ $s->isHidden(),
+ $s->setHidden(true),
+ $s->isHidden(),
+ $s->setHidden(false),
+ $s->isHidden()
+ );
+
+ $y = new ExcelBook();
+ $s = $y->addSheet("Sheet 1");
+ var_dump($s->setHidden(true));
+?>
+--EXPECT--
+bool(false)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(false)

0 comments on commit 4ad802d

Please sign in to comment.