<!--?php
header(
"Content-Type: text/html; charset=utf-8"
);
$url
=
"http://acm.wust.edu.cn/contestrank.php?cid=1014"
;
$result
=
file_get_contents
(
$url
);
$file
=
fopen
(
"content.php"
,
"w"
);
fwrite(
$file
,
$result
);
$file
=
fopen
(
"content.php"
,
"r"
);
$patt_ch
=
chr
(0x80).
"-"
.
chr
(0xff);
$namepatt
=
"()(\*{0,1}team[0-9]+)(_)([$patt_ch]+)(<\/a>)"
;
$problempatt
=
"()([0-9]+)(<\/a>)"
;
require_once
('Classes/PHPExcel.php');
require_once
('Classes/PHPExcel/Writer/Excel2007.php');
$objPHPExcel
=
new
PHPExcel();
$objPHPExcel
->getProperties()->setCreator(
"Maarten Balliauw"
);
$objPHPExcel
->getProperties()->setLastModifiedBy(
"Maarten Balliauw"
);
$objPHPExcel
->getProperties()->setTitle(
"Office 2007 XLSX Test Document"
);
$objPHPExcel
->getProperties()->setSubject(
"Office 2007 XLSX Test Document"
);
$objPHPExcel
->getProperties()->setDescription(
"Test document for Office 2007 XLSX, generated using PHP classes."
);
$objPHPExcel
->getProperties()->setKeywords(
"office 2007 openxml php"
);
$objPHPExcel
->getProperties()->setCategory(
"Test result file"
);
$row
=1;
$objPHPExcel
->getActiveSheet()->setCellValue('A'.
$row
, 'rank');
$objPHPExcel
->getActiveSheet()->setCellValue('B'.
$row
, 'team');
$objPHPExcel
->getActiveSheet()->setCellValue('C'.
$row
, 'solved');
while
(!
feof
(
$file
))
{
$line
=
fgets
(
$file
);
if
(preg_match(
"/$rankpatt/"
,
$line
,
$match
))
{
$row
++;
";
$objPHPExcel
->getActiveSheet()->setCellValue('A'.
$row
,
$match
[2]);
$objPHPExcel
->getActiveSheet()->getStyle('A'.
$row
)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
}
if
(preg_match(
"/$namepatt/"
,
$line
,
$match
))
{
";
$objPHPExcel
->getActiveSheet()->setCellValue('B'.
$row
,
$match
[2].
$match
[4]);
}
if
(preg_match(
"/$problempatt/"
,
$line
,
$match
))
{
";
$objPHPExcel
->getActiveSheet()->setCellValue('C' .
$row
,
$match
[2]);
$objPHPExcel
->getActiveSheet()->getStyle('C'.
$row
)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
}
$objWriter
=
new
PHPExcel_Writer_Excel2007(
$objPHPExcel
);
$objWriter
->save(
str_replace
('.php', '.xlsx',
__FILE__
));
}
echo
"well done:)"
;
?></a[[:space:]]></a[[:space:]]>