How to extract images from Excel files with OLE?

Perl No Comments »

#!/usr/bin/perl

use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const;
use Win32::OLE::Const 'Microsoft Excel';
$Win32::OLE::Warn = 3; # die on errors...

my $filename = 'C:\ist\Win32\OLE\ChartOLE\chart.xls';
my $filter = 'GIF'; # can be GIF, JPG, JPEG or PNG
my $count = 0;

my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', 'Quit'); # use the Excel application if it's open, otherwise open new
my $Book = $Excel->Workbooks->Open( $filename ); # open the file
foreach my $Sheet (in $Book->Sheets) { # loop through all sheets
foreach my $ChartObj (in $Sheet->ChartObjects) { # loop through all chartobjects in the sheet
my $savename = "$filename." . $count++ . ".$filter";
$ChartObj->Chart->Export({
FileName => $savename,
FilterName => $filter,
Interactive => 0});
}
}
$Book->Close;

Handling Microsoft Word and Excel files using OLE

Perl No Comments »

This perl code running under Windows 32 operating systems, and requires the MS Office to be installed.
#!/usr/bin/perl

use Win32::OLE::Const 'Microsoft Excel';
printf "xlMarkerStyleDot = %d\n", xlMarkerStyleDot;
my $wd = Win32::OLE::Const->Load("Microsoft Word 9\\.0 Object Library");
foreach my $key (keys %$wd) {
printf "$key = %s\n", $wd->{$key};
}

How to extract HREF links from the input

Perl No Comments »

#!/usr/bin/perl -n00
print "$2\n" while m{
< \s*
A \s+ HREF \s* = \s* (["']) (.*?) \1
\s* >
}gsix;

Searching in the source of a webpage

Perl No Comments »

#!/usr/bin/perl
use LWP::Simple;
$count = 0;
$search = $#ARGV >= 0 ? $ARGV[1] : "author";
$server = $#ARGV >= 1 ? $ARGV[0] : "www.webhauser.com";

$page = get "http://$server";
@lines = split /[\n\r]+/, $page;
foreach $line (@lines) {
if ( $line =~ /$search/ ) {
print "found: $line\n";
$count++;
}
}

print '-'x70 ."\n";
print "internet szerver: $server\n";
print "keresett szo: $search\n";
print "Talalat $count sorban\n";

Getting the source of a webpage

Perl No Comments »

#!/usr/bin/perl

use LWP::Simple;

print $ARGV[0];
print "\n";
getprint "http://" . $ARGV[0];

HTML/OS Desktop Link

HTML/OS No Comments »

The HTML/OS ICONPAGE variable if exists then it contains the desktop manager link. The fast, on-line Web application development practice recommends it. The HTML/OS program behaves differently when you enter the page URL as a registered start link or just open from the Web Desktop / File Manager.

[[ IF iconpage!="ERROR" THEN
  DISPLAY "<a href="+iconpage+" mce_href="+iconpage+">Desktop</a>" /DISPLAY
/IF ]]

How php sessions serializes objects?

php No Comments »

If you are using sessions and use session_register()  to register objects, these objects are serialized automatically at the end of each PHP page, and are unserialized automatically on each of the following pages. This basically means that these objects can show up on any of your pages once they become part of your session.

You don’t need to serialize an object before adding it to a session var

example:

<?php include("class.exmaple.php");
$obj = new exampel ();
$_SESSION['obj']=$obj;?>

and to resume the object:

<?php include("class.example.php");
$obj = $_SESSION['obj']); ?>

Working with php directories and files

php No Comments »

<?php
$dirName = 'images';
$dir = opendir($dirName);
while ($filename = readdir($dir)) {
  echo $filename . '<br />';
}
closedir($dir);?>

Disappearing php session data

php No Comments »

Please note that if you use a “|” sign in a variable name your entire session will be cleared, so the example below will clear out all the contents of your session.

<?php
session_start();
$_SESSION["foo|bar"] = "foo";
?>

According to this bugreport this behaviour is intended. http://bugs.php.net/bug.php?id=33786

How to use php sessions?

php No Comments »

<?php
// Use of session_register() is deprecated
$hello = "Hello world!";
session_register("hello");

// Use of $_SESSION is preferred, as of PHP 4.1.0
$_SESSION["var"] = "Setting this value to the global session variable 'var'.";

// The old way was to use $HTTP_SESSION_VARS
$HTTP_SESSION_VARS["message"] = "Hello world.";
?>

If session_start() was not called before this function is called, an implicit call to session_start() with no parameters will be made. $_SESSION does not mimic this behavior and requires session_start() before use.

WebSite Powered by webHauser
Entries RSS Comments RSS Login