The following articles mainly introduce how to export XLS database tools from MySQL. The reason why XLS database tools can be widely used in a short period of time is also because of their unique functions. The following articles mainly introduce the practical application of the XLS database tool exported from MySQL.
- warn "write to: $ARGV[0]/n";
Generate GB2312 Encoding System
- my $map = Unicode::Map->new("gb2312");
Generate Reports
My $ report = Spreadsheet: WriteExcel: Big-> new ("$ ARGV [0]") | die "cannot generate report files: $! ";
Create a report Worksheet
- my $sheet = $report->add_worksheet('data_report');
Create format
- my $title_style = $report->add_format(); $title_style->set_size(11); $title_style->set_bold(); $title_style->set_align('center');
Initialize Data Pointer
- my $sheet_col = 0;
Export the XLS database tool from MySQL to create a table
- for (my $i=0;$i<=$cols_name ;$i++) {
- $sheet->set_column($cols[$i], length($cols_name[$i])+4);
- $sheet->write_unicode($sheet_col,$i,$map->to_unicode($cols_name[$i]),$title_style);
- }
$ Sheet-> freeze_panes (1, 0); freeze rows
- while (my @row = $sth->fetchrow_array) {
- $sheet_col++;
- for (my $i=0;$i<=$cols_name ;$i++) {
- next if ($row[$i] eq '');
- $sheet->write_unicode($sheet_col,$i,$map->to_unicode($row[$i]));
- }
- }
- warn "all done!!!/n";
End
- END {
- $report->close() if ($report);
- $dbh->disconnect();
- warn "write to: $ARGV[0]/n";
Generate GB2312 Encoding System
- my $map = Unicode::Map->new("gb2312");
Generate Reports
My $ report = Spreadsheet: WriteExcel: Big-> new ("$ ARGV [0]") | die "cannot generate report files: $! ";
Create a report Worksheet
- my $sheet = $report->add_worksheet('data_report');
Create format
- my $title_style = $report->add_format(); $title_style->set_size(11); $title_style->set_bold(); $title_style->set_align('center');
Initialize Data Pointer
- my $sheet_col = 0;
Create a table
- for (my $i=0;$i<=$cols_name ;$i++) {
- $sheet->set_column($cols[$i], length($cols_name[$i])+4);
- $sheet->write_unicode($sheet_col,$i,$map->to_unicode($cols_name[$i]),$title_style);
- }
$ Sheet-> freeze_panes (1, 0); freeze rows
- while (my @row = $sth->fetchrow_array) {
- $sheet_col++;
- for (my $i=0;$i<=$cols_name ;$i++) {
- next if ($row[$i] eq '');
- $sheet->write_unicode($sheet_col,$i,$map->to_unicode($row[$i]));
- }
- }
- warn "all done!!!/n";
End
- END {
- $report->close() if ($report);
- $dbh->disconnect();
- }
The above content is an introduction to the XLS database tool exported from MySQL. I hope you will get some benefits.