How to export the XLS database tool from MySQL

Source: Internet
Author: User

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.

 
 
  1. warn "write to: $ARGV[0]/n";  

Generate GB2312 Encoding System

 
 
  1. 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

 
 
  1. my $sheet = $report->add_worksheet('data_report');  

Create format

 
 
  1. my $title_style = $report->add_format(); $title_style->set_size(11); $title_style->set_bold(); $title_style->set_align('center');  

Initialize Data Pointer

 
 
  1. my $sheet_col = 0;  

Export the XLS database tool from MySQL to create a table

 
 
  1. for (my $i=0;$i<=$cols_name ;$i++) {   
  2. $sheet->set_column($cols[$i], length($cols_name[$i])+4);   
  3. $sheet->write_unicode($sheet_col,$i,$map->to_unicode($cols_name[$i]),$title_style);   
  4. }   

$ Sheet-> freeze_panes (1, 0); freeze rows

 
 
  1. while (my @row = $sth->fetchrow_array) {   
  2. $sheet_col++;   
  3. for (my $i=0;$i<=$cols_name ;$i++) {   
  4. next if ($row[$i] eq '');   
  5. $sheet->write_unicode($sheet_col,$i,$map->to_unicode($row[$i]));   
  6. }   
  7. }   
  8. warn "all done!!!/n";   

End

 
 
  1. END {   
  2. $report->close() if ($report);   
  3. $dbh->disconnect();   
  4. warn "write to: $ARGV[0]/n";   

Generate GB2312 Encoding System

 
 
  1. 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

 
 
  1. my $sheet = $report->add_worksheet('data_report');  

Create format

 
 
  1. my $title_style = $report->add_format(); $title_style->set_size(11); $title_style->set_bold(); $title_style->set_align('center');  

Initialize Data Pointer

 
 
  1. my $sheet_col = 0;  

Create a table

 
 
  1. for (my $i=0;$i<=$cols_name ;$i++) {   
  2. $sheet->set_column($cols[$i], length($cols_name[$i])+4);   
  3. $sheet->write_unicode($sheet_col,$i,$map->to_unicode($cols_name[$i]),$title_style);   
  4. }   

$ Sheet-> freeze_panes (1, 0); freeze rows

 
 
  1. while (my @row = $sth->fetchrow_array) {   
  2. $sheet_col++;   
  3. for (my $i=0;$i<=$cols_name ;$i++) {   
  4. next if ($row[$i] eq '');   
  5. $sheet->write_unicode($sheet_col,$i,$map->to_unicode($row[$i]));   
  6. }   
  7. }   
  8. warn "all done!!!/n";   

End

 
 
  1. END {   
  2. $report->close() if ($report);   
  3. $dbh->disconnect();   
  4. }   

The above content is an introduction to the XLS database tool exported from MySQL. I hope you will get some benefits.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.