Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1716605
  • 博文数量: 362
  • 博客积分: 10587
  • 博客等级: 上将
  • 技术积分: 4098
  • 用 户 组: 普通用户
  • 注册时间: 2009-09-10 18:15
文章分类

全部博文(362)

文章存档

2014年(1)

2013年(58)

2011年(115)

2010年(112)

2009年(76)

分类:

2010-08-30 14:45:08

#!/usr/bin/perl
#Author ATGC

use strict;
use Win32::OLE;
my $excel_file = 'c:/out.xls';
my ($row,@field,$c_times,$residual,$cols,$cell_end);
my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit');
my $Book = $Excel->Workbooks->add;
my $Sheet = $Book->Worksheets(1);
my @array_cols=("Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
unlink $excel_file if (-e $excel_file);
@field=("你好","他好","大家好","就我不好");

$cols=scalar(@field);
$c_times=sprintf "%.0f",$cols/26+0.5;
$residual=$cols%26;
$cell_end = ($cols<27) ? $array_cols[$cols] : $array_cols[$c_times-1].$array_cols[$residual];
$row++;
$Sheet->Range("A$row:$cell_end$row")->{Value} = [@field];
$Book->SaveAs($excel_file);
undef($Sheet);
undef($Book);
undef($Excel);


阅读(884) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~