初始化PHP-Xlswrite扩展

This commit is contained in:
ykxiao
2024-03-05 10:01:08 +08:00
commit 879cf9584d
2483 changed files with 1054962 additions and 0 deletions

View File

@ -0,0 +1,4 @@
This directory contains some release utilities that are mainly useful
to the library developer.

View File

@ -0,0 +1,7 @@
#/bin/bash
# Perform some minor clean-ups/fixes to the docs.
perl -i -pe "s/_page/_8h/" html/pages.html
perl -i ../dev/release/fix_example_docs.pl html/examples.html
cp menudata.js html

View File

@ -0,0 +1,124 @@
#!/usr/bin/perl
#
# Simple program to arrange the example programs in a user defined order
# instead of a sorted order. Also add a caption.
#
# Copyright 2014-2021, John McNamara, jmcnamara@cpan.org
#
use warnings;
use strict;
# The required example order and descriptions.
my @examples = (
[ 'hello.c', 'A simple hello world example' ],
[ 'anatomy.c', 'The anatomy of a libxlsxwriter program' ],
[ 'demo.c', 'Demo of some of the libxlsxwriter features' ],
[ 'tutorial1.c', 'Tutorial 1 from the documentation' ],
[ 'tutorial2.c', 'Tutorial 2 from the documentation' ],
[ 'tutorial3.c', 'Tutorial 3 from the documentation' ],
[ 'format_font.c', 'Example of writing data with font formatting' ],
[ 'format_num_format.c', 'Example of writing data with number formatting' ],
[ 'dates_and_times01.c', 'Writing dates and times with numbers' ],
[ 'dates_and_times02.c', 'Writing dates and times with datetime' ],
[ 'dates_and_times03.c', 'Writing dates and times with Unix datetimes' ],
[ 'dates_and_times04.c', 'Dates and times with different formats' ],
[ 'hyperlinks.c', 'A example of writing urls/hyperlinks' ],
[ 'rich_strings.c', 'A example of writing "rich" multi-format strings' ],
[ 'array_formula.c', 'A example of using array formulas' ],
[ 'dynamic_arrays.c', 'A example of using Excel 365 dynamic array formulas' ],
[ 'utf8.c', 'A example of some UTF-8 text' ],
[ 'constant_memory.c', 'Write a large file with constant memory usage' ],
[ 'merge_range.c', 'Create a merged range of cells' ],
[ 'merge_rich_string.c', 'Create a merged range with a rich string' ],
[ 'autofilter.c', 'An example of a worksheet autofilter' ],
[ 'data_validate.c', 'Examples of worksheet data validation and drop down lists' ],
[ 'conditional_format1.c', 'A simple conditional formatting example' ],
[ 'conditional_format2.c', 'An advanced conditional formatting example' ],
[ 'images.c', 'Example of adding images to a worksheet.' ],
[ 'image_buffer.c', 'Example of adding an image from a memory buffer.' ],
[ 'headers_footers.c', 'Example of adding worksheet headers/footers' ],
[ 'defined_name.c', 'Example of how to create defined names' ],
[ 'outline.c', 'Example of grouping and outlines' ],
[ 'outline_collapsed.c', 'Example of grouping and collapsed outlines' ],
[ 'background.c', 'Example of how to set the background image for a worksheet' ],
[ 'tab_colors.c', 'Example of how to set worksheet tab colors' ],
[ 'diagonal_border.c', 'Example of how to set a worksheet cell diagonal border.' ],
[ 'hide_sheet.c', 'Example of hiding a worksheet' ],
[ 'doc_properties.c', 'Example of setting workbook doc properties' ],
[ 'doc_custom_properties.c','Example of setting custom doc properties' ],
[ 'worksheet_protection.c', 'Example of enabling worksheet protection' ],
[ 'hide_row_col.c', 'Example of hiding worksheet rows and columns' ],
[ 'comments1.c', 'Example of adding cell comments to a worksheet' ],
[ 'comments2.c', 'Example of adding cell comments with options' ],
[ 'macro.c', 'Example of adding a VBA macro to a workbook' ],
[ 'panes.c', 'Example of how to create worksheet panes' ],
[ 'ignore_errors.c', 'Example of ignoring worksheet errors/warnings' ],
[ 'lambda.c', 'Example of using the EXCEL 365+ LAMBDA() function' ],
[ 'chart.c', 'Example of a simple column chart' ],
[ 'chart_area.c', 'Examples of area charts' ],
[ 'chart_bar.c', 'Examples of bar charts' ],
[ 'chart_column.c', 'Examples of column charts' ],
[ 'chart_line.c', 'Example of a line chart' ],
[ 'chart_scatter.c', 'Examples of scatter charts' ],
[ 'chart_radar.c', 'Examples of radar charts' ],
[ 'chart_pie.c', 'Examples of pie charts' ],
[ 'chart_doughnut.c', 'Examples of doughnut charts' ],
[ 'chart_clustered.c', 'Examples of clustered category chart' ],
[ 'chart_data_table.c', 'Examples of charts with data tables' ],
[ 'chart_data_tools.c', 'Examples of charts data tools' ],
[ 'chart_data_labels.c', 'Examples of charts data labels' ],
[ 'chart_fonts.c', 'Examples of using charts fonts' ],
[ 'chart_pattern.c', 'Examples of using charts patterns' ],
[ 'chart_styles.c', 'Examples of built-in charts styles' ],
[ 'chartsheet.c', 'Example of a chartsheet chart' ],
);
# Convert the array refs to a hash for lookups.
my %examples;
for my $example (@examples) {
$examples{$example->[0]} = 1;
}
my $in_list = 0;
while ( my $line = <> ) {
# Print all lines not in the <ul> list.
print $line if !$in_list;
# Check for <ul> list.
if ( $line =~ /<div class="textblock">/ ) {
$in_list = 1;
}
# Capture the <li> items of the list.
if ( $line =~ /<li><a class="el" href="[^"]+">([^<]+)/ ) {
my $example = $1;
# Warn if there are any new/unkown items.
if ( !exists $examples{$example} ) {
warn "$0 Unknown example: $example\n";
}
next;
}
# At the end of the <ul> list print out the <li> items in user defined order.
if ( $line =~ m{^</ul>} ) {
$in_list = 0;
for my $aref ( @examples ) {
my $example = $aref->[0];
my $filename = $aref->[0];
my $desc = $aref->[1];
$example =~ s/\.c/_8c-example.html/;
printf qq(<li><a class="el" href="%s">%s</a> %s</li>\n\n),
$example, $filename, $desc;
}
print $line;
}
}
__END__

View File

@ -0,0 +1,78 @@
#!/usr/bin/perl
#
# Simple program to generate the examples.dox file from a simple text file,
# with links to the next/previous examples.
#
# Copyright 2014-2021, John McNamara, jmcnamara@cpan.org
#
use strict;
use warnings;
my @examples;
my @sections;
my @links;
my $buffer = '';
# Sample through the example sections and break the text into blocks.
while ( my $line = <> ) {
# Ignore comments in the input file.
next if $line =~ /^#/;
# Match the start of an example block.
if ( $line =~ /^\@example/ ) {
chomp $buffer;
# Store the example name and the section body.
push @examples, $line;
push @sections, $buffer;
$buffer = '';
next;
}
$buffer .= $line;
}
# Store the last example section and omit the first blank element.
push @sections, $buffer;
shift @sections;
# Generate a set of @ref links targets from the example program names.
for ( @examples ) {
my $link = $_;
chomp $link;
$link =~ s/\@example //;
push @links, [ $link, $link ];
}
# Add the first and last links back to the examples.
unshift @links, [ "examples", "Examples page" ];
push @links, [ "examples", "Examples page" ];
# Add the start of the Doxygen header.
print "/**\n";
print "\@page examples Example Programs\n\n";
# Print out each section.
for my $i ( 0 .. @examples - 1 ) {
print $examples[$i];
# Add a simple header table with next/previous links.
printf qq{\n<table width="600">\n};
printf qq{<tr>\n};
printf qq{ <td>\@ref %s "&lt;&lt; %s"</td>\n},
$links[$i]->[0], $links[$i]->[1];
printf qq{ <td align="right">\@ref %s "%s &gt;&gt;"</td>\n},
$links[ $i + 2 ]->[0], $links[ $i + 2 ]->[1];
printf qq{</tr>\n};
printf qq{</table>\n};
print $sections[$i], "\n\n\n\n";
}
# Print the end of the doxygen comment.
print "*/\n";

View File

@ -0,0 +1,49 @@
#!/usr/bin/perl
#
# Simple program to generate the string array for the lxw_strerror() function
# from the Doxygen comments in the lxw_error enum:
#
# perl dev/release/gen_error_strings.pl include/xlsxwriter/common.h
#
# Copyright 2014-2021, John McNamara, jmcnamara@cpan.org
#
use warnings;
use strict;
my $in_enum = 0;
my @strings;
my $filename = shift || 'include/xlsxwriter/common.h';
open my $fh, '<', $filename or die "Couldn't open $filename: $!\n";
while (<$fh>) {
$in_enum = 1 if /typedef enum lxw_error/;
$in_enum = 0 if /} lxw_error;/;
# Match doxygen strings in the enum.
if ($in_enum && m{/\*\*}) {
# Strip the comment parts.
s{/\*\*}{};
s{\*/}{};
s{^\s+}{};
s{\s+$}{};
push @strings, $_;
}
}
# Print out an array of strings based on the doxygen comments.
print "\n";
print "// Copy to src/utility.c\n\n";
print "char *error_strings[LXW_MAX_ERRNO + 1] = {\n";
for my $string (@strings) {
print qq{ "$string",\n};
}
print qq{ "Unknown error number."\n};
print "};\n\n";

View File

@ -0,0 +1,36 @@
#!/usr/bin/perl
#
# Simple program to generate the coccoapods unbrella file.
# Run from the libxlsxwriter root dir.
#
# Copyright 2014-2021, John McNamara, jmcnamara@cpan.org
#
use warnings;
use strict;
use File::Find;
my @includes;
# Callback to match header files.
sub match_include {
push @includes, $File::Find::name if /^.*\.h\z/s;
}
# Use File::Find to find header files.
find({wanted => \&match_include}, 'include/xlsxwriter');
# Sort and remove leading dirs from the include files.
@includes = sort @includes;
s{^include/xlsxwriter/}{} for @includes;
# Generate the unbrella file.
print qq{#import <Foundation/Foundation.h>\n\n};
print qq{#import "../xlsxwriter.h"\n};
print qq{#import "$_"\n} for @includes;
print qq{\n};
print qq{FOUNDATION_EXPORT double xlsxwriterVersionNumber;\n};
print qq{FOUNDATION_EXPORT const unsigned char xlsxwriterVersionString[];\n\n};

View File

@ -0,0 +1,50 @@
#!/usr/bin/perl
#
# Simple program to generate a Windows .def file from the exported symbols in
# libxlsxwriter.a.
#
# perl dev/release/gen_windows_def_file.pl lib/libxlsxwriter.a
#
# Copyright 2014-2021, John McNamara, jmcnamara@cpan.org
#
use warnings;
use strict;
my $lib_file = shift;
die "$0: Path to .a lib file required.\n" if !$lib_file;
die "$0: File '$lib_file' not found\n" if !-e $lib_file;
# Get the symbols from the libxlsxwriter.a file.
my @symbols = `nm $lib_file`;
my %unique;
for my $symbol ( @symbols ) {
chomp $symbol;
# Get the last field in the row.
my @fields = split " ", $symbol;
$symbol = $fields[-1];
next unless $symbol;
# Skip symbols not belonging to libxlsxwriter.
next if $symbol !~ /^_(lxw|work|format|chart|new)/;
# Skip some the RedBlack functions.
next if $symbol =~ m{RB};
# Strip the leading underscore.
$symbol =~ s/^_//;
# Remove duplicate instances of some symbols.
$unique{$symbol}++;
}
# Generate the .def file.
print "EXPORTS\r\n";
for my $symbol ( sort keys %unique ) {
print " ", $symbol, "\r\n";
}

View File

@ -0,0 +1,10 @@
prefix=@PREFIX@
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib
Name: libxlsxwriter
Description: A C library for creating Excel XLSX files
Version: @VERSION@
Cflags: -I${includedir}
Libs: -L${libdir} -lxlsxwriter -lz

View File

@ -0,0 +1,332 @@
#!/bin/bash
clear
echo "|"
echo "| Pre-release checks."
echo "|"
echo
#############################################################
#
# Run tests.
#
function check_test_status {
echo
echo -n "Are all tests passing? [y/N]: "
read RESPONSE
if [ "$RESPONSE" != "y" ]; then
echo -n " Run all tests now? [y/N]: "
read RESPONSE
if [ "$RESPONSE" != "y" ]; then
echo
echo -e "Please run: make test\n";
exit 1
else
echo " Running tests...";
make test
check_test_status
fi
fi
}
#############################################################
#
# Run test for C++ const correctness.
#
function check_test_const {
echo
echo -n "Is the const test passing? [y/N]: "
read RESPONSE
if [ "$RESPONSE" != "y" ]; then
echo -n " Run test now? [y/N]: "
read RESPONSE
if [ "$RESPONSE" != "y" ]; then
echo
echo -e "Please run: make test_const\n";
exit 1
else
echo " Running test...";
make test_const
check_test_const
fi
fi
}
#############################################################
#
# Run spellcheck.
#
function check_spellcheck {
echo
echo -n "Is the spellcheck ok? [y/N]: "
read RESPONSE
if [ "$RESPONSE" != "y" ]; then
echo -n " Run spellcheck now? [y/N]: "
read RESPONSE
if [ "$RESPONSE" != "y" ]; then
echo
echo -e "Please run: make spellcheck\n";
exit 1
else
echo " Running spellcheck...";
make spellcheck
check_spellcheck
fi
fi
}
#############################################################
#
# Check Changes file is up to date.
#
function check_changefile {
clear
echo "Latest change in Changes file: "
perl -ne '$rev++ if /^##/; exit if $rev > 1; print " | $_"' Changes.txt
echo
echo -n "Is the Changes file updated? [y/N]: "
read RESPONSE
if [ "$RESPONSE" != "y" ]; then
echo
echo -e "Please update the Change file to proceed.\n";
exit 1
fi
}
#############################################################
#
# Check the versions are up to date.
#
function check_versions {
clear
echo
echo "Latest file versions: "
echo
awk '/s.version / {print "\t" FILENAME "\t" $1 "\t" $3}' libxlsxwriter.podspec
awk '/ LXW/ {print "\t" FILENAME "\t" $2 "\t" $3}' include/xlsxwriter.h
echo
echo -n "Are the versions up to date? [y/N]: "
read RESPONSE
if [ "$RESPONSE" != "y" ]; then
echo -n " Update versions? [y/N]: "
read RESPONSE
if [ "$RESPONSE" != "y" ]; then
echo
echo -e "Please update the versions to proceed.\n";
exit 1
else
echo " Updating versions...";
perl -i dev/release/update_revison.pl include/xlsxwriter.h libxlsxwriter.podspec
check_versions
fi
fi
}
#############################################################
#
# Check that the docs build cleanly.
#
function check_docs {
# clear
echo
echo -n "Do the docs build cleanly? [y/N]: "
read RESPONSE
if [ "$RESPONSE" != "y" ]; then
echo -n " Build docs now? [y/N]: "
read RESPONSE
if [ "$RESPONSE" != "y" ]; then
echo
echo -e "Please run: make docs\n";
exit 1
else
echo " Building docs...";
make docs
check_docs
fi
fi
}
#############################################################
#
# Generate the cocoapods umbrella file.
#
function gen_umbrella_file {
echo
echo -n "Is the umbrella file up to date? [y/N]: "
read RESPONSE
if [ "$RESPONSE" != "y" ]; then
echo -n " Update umbrella file now? [y/N]: "
read RESPONSE
if [ "$RESPONSE" != "y" ]; then
echo
echo -e "Please update cocoapods/libxlsxwriter-umbrella.h\n";
exit 1
else
echo " Updating file...";
perl dev/release/gen_umbrella_file.pl > cocoapods/libxlsxwriter-umbrella.h
fi
fi
}
#############################################################
#
# Check the cocoapods spec file.
#
function check_pod_spec {
echo
echo -n "Is the coacoapod file ok? [y/N]: "
read RESPONSE
if [ "$RESPONSE" != "y" ]; then
echo -n " Run lint now? [y/N]: "
read RESPONSE
if [ "$RESPONSE" != "y" ]; then
echo
echo -e "Please run: pod spec lint libxlsxwriter.podspec\n";
exit 1
else
echo " Running lint...";
pod spec lint libxlsxwriter.podspec --use-libraries
check_pod_spec
fi
fi
}
#############################################################
#
# Update the pod repo. This can take some time.
#
function update_pod_repo {
echo
echo -n "Is the pod repo updated? [y/N]: "
read RESPONSE
if [ "$RESPONSE" != "y" ]; then
echo -n " Update now? [y/N]: "
read RESPONSE
if [ "$RESPONSE" != "y" ]; then
echo
echo -e "Please run: pod spec lint libxlsxwriter.podspec\n";
exit 1
else
echo " Running update...";
cd ~/.cocoapods/repos/master
git pull --ff-only
cd -
update_pod_repo
fi
fi
}
#############################################################
#
# Run release checks.
#
function check_git_status {
clear
echo "Git status: "
git status | awk '{print " | ", $0}'
echo "Git log: "
git log -1 | awk '{print " | ", $0}'
echo "Git latest tag: "
git tag -l -n1 | tail -1 | awk '{print " | ", $0}'
echo
echo -n "Is the git status okay? [y/N]: "
read RESPONSE
if [ "$RESPONSE" != "y" ]; then
echo
echo -e "Please fix git status.\n";
echo -e "\ngit add -u";
git tag -l -n1 | tail -1 | perl -lane 'printf "git commit -m \"Prep for release %s\"\ngit tag \"%s\"\n\n", $F[4], $F[0]' | perl dev/release/update_revison.pl
exit 1
fi
}
check_test_status
clear
check_test_const
clear
check_spellcheck
clear
check_docs
check_changefile
clear
gen_umbrella_file
check_pod_spec
clear
update_pod_repo
check_versions
check_git_status
#############################################################
#
# All checks complete.
#
clear
echo
echo "Everything is configured.";
echo
echo -n "Confirm release: [y/N]: ";
read RESPONSE
if [ "$RESPONSE" == "y" ]; then
exit 0
else
exit 1
fi

View File

@ -0,0 +1,42 @@
#!/usr/bin/perl
# Simple script to increment x.y.z style version numbers in a file.
use strict;
use warnings;
use Perl::Version;
while (<>) {
# Increment any x.y.z version strings.
if (m/(\d\.\d\.\d)/) {
my $version = Perl::Version->new( $1 );
# Components are: revision, version and subversion.
if ( $version->version == 9 && $version->subversion == 9 ) {
$version->inc_revision();
}
elsif ( $version->subversion == 9 ) {
$version->inc_version();
}
else {
$version->inc_subversion();
}
my $new_version = $version->stringify();
s/\d\.\d\.\d/$new_version/;
}
# Increment the LXW_VERSION_ID number in xlsxwriter.h
if (m/LXW_VERSION_ID (\d+)/) {
my $version = $1;
my $new_version = $version + 1;
s/\d+/$new_version/;
}
print;
}
__END__