作者darkleo (里歐)
看板Perl
標題[問題] Perl 寫入 Excel 的問題
時間Wed Dec 2 14:23:33 2015
#!/usr/bin/perl
use Win32::OLE;
$xlApp = Win32::OLE->new('Excel.Application');
$xlApp->{Visible} = 1;
# Create a new workbook
$xlBook = $xlApp->Workbooks->Add;
$col = $row = 1;
$xlBook->write($row, $col, 'aa');
$xlBook->write(1, $col, 'bb');
$xlBook->write('A3', 123);
exit;
# Wait for user input...
print "Press <return> to continue...";
$x = <STDIN>;
# Clean up
$xlBook->{Saved} = 1;
$xlApp->Quit;
$xlBook = 0;
$xlApp = 0;
print "All done.";
程式碼如上,不知道為何只能開啟Excel後,卻沒有在相對應位置輸入字
是語法有錯還是少安裝了什麼嗎??
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 211.75.12.108
※ 文章網址: https://www.ptt.cc/bbs/Perl/M.1449037415.A.5E0.html
→ CindyLinz: 沒有用過 Win32::OLE.. QQ 不過我看說明裡面的範例 12/02 16:01
→ CindyLinz: 儲存格的寫法是 $sheet->Cells(1,1)->{Value} = "foo"; 12/02 16:01
→ CindyLinz: 這樣欸? 12/02 16:01
→ CindyLinz: $sheet = $xlBook->Worksheets(1); 12/02 16:02
→ darkleo: 嗯?不然還有什麼其他的可以輸入Excel嘛!? 12/02 16:33
→ Neisseria: 看看 Spreadsheet::WriteExcel 或 Data::Table::Excel 12/02 16:48
→ CindyLinz: 你的寫法和 sample 不一樣啊? 不試試 sample 的寫法嗎? 12/02 21:34