From 9c746bc6cd23fed41babc3875618c8821d5ab7d7 Mon Sep 17 00:00:00 2001 From: Marc Schwartz Date: Tue, 21 Jan 2014 09:45:05 -0600 Subject: [PATCH] Fixed bugs related to Encoding = "latin1" and freezing columns and rows in XLS files. Bumping to 3.3.1 and submitting to CRAN. --- DESCRIPTION | 4 ++-- inst/Perl/WriteXLS.pl | 8 ++++---- inst/Perl/WriteXLSX.pl | 8 ++++---- man/WriteXLS.Rd | 4 ++++ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b9cdb65..ce3a367 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: WriteXLS -Version: 3.2.2 -Date: 2013-11-12 +Version: 3.3.1 +Date: 2014-01-20 Title: Cross-platform Perl based R function to create Excel 2003 (XLS) and Excel 2007 (XLSX) files Description: Cross-platform Perl based R function to create Excel 2003 (XLS) and Excel 2007 (XLSX) files from one or more data frames. Each data frame will be diff --git a/inst/Perl/WriteXLS.pl b/inst/Perl/WriteXLS.pl index 3dc03b9..663ee3f 100755 --- a/inst/Perl/WriteXLS.pl +++ b/inst/Perl/WriteXLS.pl @@ -6,7 +6,7 @@ # # Write to an Excel binary file. # -# Copyright 2013, Marc Schwartz +# Copyright 2014, Marc Schwartz # # This software is distributed under the terms of the GNU General # Public License Version 2, June 1991. @@ -279,7 +279,7 @@ sub string_width { if ($Encoding eq "UTF-8") { $WorkSheet->write_comment(0, $Column, decode_utf8($Fld)); } else { - $WorkSheet->write_comment(0, $Column, decode_utf8("iso-8859-1", $Fld)); + $WorkSheet->write_comment(0, $Column, decode("iso-8859-1", $Fld)); } } @@ -293,7 +293,7 @@ sub string_width { if ($Encoding eq "UTF-8") { $WorkSheet->write($Row, $Column, decode_utf8($Fld)); } else { - $WorkSheet->write($Row, $Column, decode_utf8("iso-8859-1", $Fld)); + $WorkSheet->write($Row, $Column, decode("iso-8859-1", $Fld)); } $Column++; @@ -316,7 +316,7 @@ sub string_width { $WorkSheet->autofilter(0, 0, $Row - 1, $Column - 1); } - if (($FreezeRow != 0) && ($FreezeCol != 0)) { + if (($FreezeRow > 0) || ($FreezeCol > 0)) { $WorkSheet->freeze_panes($FreezeRow, $FreezeCol); } } diff --git a/inst/Perl/WriteXLSX.pl b/inst/Perl/WriteXLSX.pl index 774d4d1..223f868 100755 --- a/inst/Perl/WriteXLSX.pl +++ b/inst/Perl/WriteXLSX.pl @@ -6,7 +6,7 @@ # # Write to an Excel binary file. # -# Copyright 2013, Marc Schwartz +# Copyright 2014, Marc Schwartz # # This software is distributed under the terms of the GNU General # Public License Version 2, June 1991. @@ -279,7 +279,7 @@ sub string_width { if ($Encoding eq "UTF-8") { $WorkSheet->write_comment(0, $Column, decode_utf8($Fld)); } else { - $WorkSheet->write_comment(0, $Column, decode_utf8("iso-8859-1", $Fld)); + $WorkSheet->write_comment(0, $Column, decode("iso-8859-1", $Fld)); } } @@ -293,7 +293,7 @@ sub string_width { if ($Encoding eq "UTF-8") { $WorkSheet->write($Row, $Column, decode_utf8($Fld)); } else { - $WorkSheet->write($Row, $Column, decode_utf8("iso-8859-1", $Fld)); + $WorkSheet->write($Row, $Column, decode("iso-8859-1", $Fld)); } $Column++; @@ -316,7 +316,7 @@ sub string_width { $WorkSheet->autofilter(0, 0, $Row - 1, $Column - 1); } - if (($FreezeRow != 0) || ($FreezeCol != 0)) { + if (($FreezeRow > 0) || ($FreezeCol > 0)) { $WorkSheet->freeze_panes($FreezeRow, $FreezeCol); } } diff --git a/man/WriteXLS.Rd b/man/WriteXLS.Rd index cbe0566..03eb494 100644 --- a/man/WriteXLS.Rd +++ b/man/WriteXLS.Rd @@ -222,6 +222,9 @@ WriteXLS("iris", "irisrownames.xlsx", AdjWidth = TRUE, BoldHeaderRow = TRUE, row.names = TRUE) + # Use latin1 Encoding + WriteXLS("iris", "irisLatin1.xls", Encoding = "latin1") + # Clean up and delete XLS files rm(iris.split) unlink("iris.xls") @@ -229,6 +232,7 @@ unlink("irissplit.xls") unlink("iriscomments.xlsx") unlink("irisrownames.xlsx") + unlink("irisLatin1.xls") } } \keyword{file}