Posted on 2009-04-13 10:36:02-07 by smc in response to 8921
Re: Autofilter in Calc (solution)

It appears to me that you need to add the raw XML code to accomplish this now. Fortunately this isn't too hard once you do the necessary reverse engineering. :-)

my $xml = '<table:database-ranges>' . '<table:database-range table:target-range-address="' . $sheetname . '.A1:' . $sheetname . '.U' . $ +row_cnt . '" table:display-filter-buttons="true"/>' . '</table:database-ranges>'; my $xmlpos = $doc->getElement('//table:table', 0); $doc->insertElement ( $xmlpos, $xml, position => 'after' );

In the above example:

$xml is the raw xml we need to insert into our spreadsheet.

$sheetname is the name of the worksheet (a scalar, not a ref to the sheet). Note that some characters in the sheetname, such as a period, will cause this not to work.

A1 is the starting coordinate for the autofilter. U is the ending column, $row_cnt is the number of rows in the auto filter range (you could also parametrize the U).

I also tried using appendElement with similar syntax, but it was nesting the new xml within </table:table> instead of after it. A bug?

Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.