Monastery: I am trying to create an excel worksheet using CPAN's writeexcel module. The script works as long as I dont use threads. The moment I try the function through a thread the following happens. 1)script would seem to work if the workbook object were passed to the thread , but the saved excel file would not have data on it. 2)If I try to pass in the worksheet object to the thread the excel file becomes corrupt. Tried all techniques using shared Workbook and Worksheet objects , but had no luck. I had also been through lot of examples and documentation on the Web related to ithreads , thread models and so on , but did not come across anything close to this issue. Would like to know of any feedback the monastery has had with similar attempts made earlier. Here is the script stripped down to the barebone. The original Thought was to gain time at creating a multi tabbed excel file , in which a each tab would be handled by a single thread using an explicit csv file.
#!perl use strict; use warnings; use threads; use threads::shared; use Spreadsheet::WriteExcel; my $workbook = Spreadsheet::WriteExcel->new('test.xls'); my $worksheet = $workbook->add_worksheet('sample'); #---this works processfile($worksheet); #--this will corrupt excel file , irrespective of worksheet being shar +ed or private. #threads->new(\&processfile,$worksheet)->join(); $workbook->close(); sub processfile { my($wrksheet)=@_; $wrksheet->write(0, 0, "Hi Excel!" +); return ; }
In reply to Excel Worksheets and Perl iThread by KarlCiaran
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |