请问,如何利用PERL将生成的表格以excel图表的形式嵌套在浏览器中显示.

justdooracle 2004-08-09 03:49:32
需求:
1.perl中处理的数据表是通过mysql数据库查询的结果,这个结果需要能够写入到excel中.

2.将这些数据以excel图表的形式,如饼图 显示在ie浏览器中.

其中1.好象可以实现,但是2我不知道该怎么办,谢谢高手指教.

如果perl/cgi不行,php可以吗? 服务器是apache,freebsd的,asp/asp.net环境肯定是不行的,谢谢:(
...全文
321 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
pwtitle 2004-08-09
  • 打赏
  • 举报
回复
使用owc,需要客户端安装office.完全调用execl图表等等。
keaizhong 2004-08-09
  • 打赏
  • 举报
回复

//--------------折线图
function imageLine(){
$item_array=Split($this->ARRAYSPLIT,$this->ITEMARRAY);
$num=Count($item_array);
$item_max=0;
for ($i=0;$i<$num;$i++){
$item_max=Max($item_max,$item_array[$i]);
}
//$xx=$this->BORDER;
//画柱形图
for ($i=0;$i<$num;$i++){
srand((double)microtime()*1000000);
if($this->R!=255 && $this->G!=255 && $this->B!=255){
$R=Rand($this->R,200);
$G=Rand($this->G,200);
$B=Rand($this->B,200);
}else{
$R=Rand(50,200);
$G=Rand(50,200);
$B=Rand(50,200);
}
$color=ImageColorAllocate($this->IMAGE,$R,$G,$B);
//柱形高度
$height_now=($this->Y-$this->BORDER)-($this->Y-$this->BORDER*2)*($item_array[$i]/$item_max);
if($i!="0"){
ImageLine($this->IMAGE,$xx,$height_next,$xx+$this->BORDER,$height_now,$color);
}
ImageString($this->IMAGE,$this->FONTSIZE,$xx+$this->BORDER,$height_now-$this->BORDER/2,$item_array[$i],$this->FONTCOLOR);
$height_next=$height_now;
//用于间隔
$xx=$xx+$this->BORDER;
}
}
//--------------饼状图
function imageCircle(){
$item_array=Split($this->ARRAYSPLIT,$this->ITEMARRAY);
$num=Count($item_array);
$item_max=0;
for ($i=0;$i<$num;$i++){
$item_max=Max($item_max,$item_array[$i]);
$total += $item_array[$i];
}
$yy=$this->Y-$this->BORDER*2;

//画饼状图的阴影部分
$e=0;
for ($i=0;$i<$num;$i++){
srand((double)microtime()*1000000);
if($this->R!=255 && $this->G!=255 && $this->B!=255){
$R=Rand($this->R,200);
$G=Rand($this->G,200);
$B=Rand($this->B,200);
}else{
$R=Rand(50,200);
$G=Rand(50,200);
$B=Rand(50,200);
}
$s=$e;
$leight=$item_array[$i]/$total*360;
$e=$s+$leight;
$color=ImageColorAllocate($this->IMAGE,$R,$G,$B);
$colorarray[$i]=$color;
//画圆
for ($j = 90; $j > 70; $j--) imagefilledarc($this->IMAGE, 110, $j, 200, 100, $s, $e, $color, IMG_ARC_PIE);
//imagefilledarc($this->IMAGE, 110, 70, 200, 100, $s, $e, $color, IMG_ARC_PIE);
//ImageFilledRectangle($this->IMAGE,$this->BORDER,$yy-$this->BORDER,$leight,$yy,$color);
//ImageString($this->IMAGE,$this->FONTSIZE,$leight+2,$yy-$this->BORDER,$item_array[$i],$this->FONTCOLOR);
//用于间隔
$yy=$yy-$this->BORDER*2;
}

//画饼状图的表面部分
$e=0;
for ($i=0;$i<$num;$i++){
srand((double)microtime()*1000000);
if($this->R!=255 && $this->G!=255 && $this->B!=255){
$R=Rand($this->R,200);
$G=Rand($this->G,200);
$B=Rand($this->B,200);
}else{
$R=Rand(50,200);
$G=Rand(50,200);
$B=Rand(50,200);
}
$s=$e;
$leight=$item_array[$i]/$total*360;
$e=$s+$leight;
//$color=$colorarray[$i];
$color=ImageColorAllocate($this->IMAGE,$R,$G,$B);
//画圆
//for ($j = 90; $j > 70; $j--) imagefilledarc($this->IMAGE, 110, $j, 200, 100, $s, $e, $color, IMG_ARC_PIE);
imagefilledarc($this->IMAGE, 110, 70, 200, 100, $s, $e, $color, IMG_ARC_PIE);
}
}
//--------------完成打印图形
function printAll(){
ImagePNG($this->IMAGE);
ImageDestroy($this->IMAGE);
}
//--------------调试
function debug(){
echo "X:".$this->X."<br/>Y:".$this->Y;
echo "<br/>BORDER:".$this->BORDER;
$item_array=split($this->ARRAYSPLIT,$this->ITEMARRAY);
$num=Count($item_array);
echo "<br/>数值个数:".$num."<br/>数值:";
for ($i=0;$i<$num;$i++){
echo "<br/>".$item_array[$i];
}
}
}
//$report->debug();//调式之用

Header( "Content-type:image/png");
$report=new ImageReport;
$report->setImage(600,300,255,255,255,1);//参数(长,宽,背影色R,G,B,是否透明1或0)
$temparray="100,260,400,320,260,120";//数值,用指定符号隔开
$report->setItem(',',$temparray,4,20);//参数(分隔数值的指定符号,数值变量,样式1为竖柱图2为横柱图3为折线图4为饼图,距离)
$report->setFont(1);//字体大小1-10
$report->PrintReport();
?>


keaizhong 2004-08-09
  • 打赏
  • 举报
回复

图类,可显示多种图形
<?//图类
Class ImageReport{
var $X;//图片大小X轴
var $Y;//图片大小Y轴
var $R;//背影色R值
var $G;//...G.
var $B;//...B.
var $TRANSPARENT;//是否透明1或0
var $IMAGE;//图片对像
//-------------------
var $ARRAYSPLIT;//指定用于分隔数值的符号
var $ITEMARRAY;//数值
var $REPORTTYPE;//图表类型,1为竖柱形2为横柱形3为折线形
var $BORDER;//距离
//-------------------
var $FONTSIZE;//字体大小
var $FONTCOLOR;//字体颜色
//--------参数设置函数
function setImage($SizeX,$SizeY,$R,$G,$B,$Transparent){
$this->X=$SizeX;
$this->Y=$SizeY;
$this->R=$R;
$this->G=$G;
$this->B=$B;
$this->TRANSPARENT=$Transparent;
}
function setItem($ArraySplit,$ItemArray,$ReportType,$Border){
$this->ARRAYSPLIT=$ArraySplit;
$this->ITEMARRAY=$ItemArray;
$this->REPORTTYPE=$ReportType;
$this->BORDER=$Border;
}
function setFont($FontSize){
$this->FONTSIZE=$FontSize;
}
//----------------主体
function PrintReport(){
//建立画布大小
$this->IMAGE=ImageCreate($this->X,$this->Y);
//设定画布背景色
$background=ImageColorAllocate($this->IMAGE,$this->R,$this->G,$this->B);
if($this->TRANSPARENT=="1"){
//背影透明
Imagecolortransparent($this->IMAGE,$background);
}else{
//如不要透明时可填充背景色
ImageFilledRectangle($this->IMAGE,0,0,$this->X,$this->Y,$background);
}
//参数字体文小及颜色
$this->FONTCOLOR=ImageColorAllocate($this->IMAGE,255-$this->R,255-$this->G,255-$this->B);
Switch ($this->REPORTTYPE){
case "0":
break;
case "1":
$this->imageColumnS();
break;
case "2":
$this->imageColumnH();
break;
case "3":
$this->imageLine();
break;
case "4":
$this->imageCircle();
break;
}
$this->printXY();
$this->printAll();
}
//-----------打印XY坐标轴
function printXY(){
//画XY坐标轴*/
$color=ImageColorAllocate($this->IMAGE,255-$this->R,255-$this->G,255-$this->B);
$xx=$this->X/10;
$yy=$this->Y-$this->Y/10;
ImageLine($this->IMAGE,$this->BORDER,$this->BORDER,$this->BORDER,$this->Y-$this->BORDER,$color);//X轴
ImageLine($this->IMAGE,$this->BORDER,$this->Y-$this->BORDER,$this->X-$this->BORDER,$this->Y-$this->BORDER,$color);//y轴
//Y轴上刻度
$rulerY=$this->Y-$this->BORDER;
while($rulerY>$this->BORDER*2){
$rulerY=$rulerY-$this->BORDER;
ImageLine($this->IMAGE,$this->BORDER,$rulerY,$this->BORDER-2,$rulerY,$color);
}
//X轴上刻度
$rulerX=$rulerX+$this->BORDER;
while($rulerX<($this->X-$this->BORDER*2)){
$rulerX=$rulerX+$this->BORDER;
//ImageLine($this->IMAGE,$this->BORDER,10,$this->BORDER+10,10,$color);
ImageLine($this->IMAGE,$rulerX,$this->Y-$this->BORDER,$rulerX,$this->Y-$this->BORDER+2,$color);
}
}

//--------------竖柱形图
function imageColumnS(){
$item_array=Split($this->ARRAYSPLIT,$this->ITEMARRAY);
$num=Count($item_array);
$item_max=0;
for ($i=0;$i<$num;$i++){
$item_max=Max($item_max,$item_array[$i]);
}
$xx=$this->BORDER*2;
//画柱形图
for ($i=0;$i<$num;$i++){
srand((double)microtime()*1000000);
if($this->R!=255 && $this->G!=255 && $this->B!=255){
$R=Rand($this->R,200);
$G=Rand($this->G,200);
$B=Rand($this->B,200);
}else{
$R=Rand(50,200);
$G=Rand(50,200);
$B=Rand(50,200);
}
$color=ImageColorAllocate($this->IMAGE,$R,$G,$B);
//柱形高度
$height=($this->Y-$this->BORDER)-($this->Y-$this->BORDER*2)*($item_array[$i]/$item_max);
ImageFilledRectangle($this->IMAGE,$xx,$height,$xx+$this->BORDER,$this->Y-$this->BORDER,$color);
ImageString($this->IMAGE,$this->FONTSIZE,$xx,$height-$this->BORDER,$item_array[$i],$this->FONTCOLOR);
//用于间隔
$xx=$xx+$this->BORDER*2;
}
}
//-----------横柱形图
function imageColumnH(){
$item_array=Split($this->ARRAYSPLIT,$this->ITEMARRAY);
$num=Count($item_array);
$item_max=0;
for ($i=0;$i<$num;$i++){
$item_max=Max($item_max,$item_array[$i]);
}
$yy=$this->Y-$this->BORDER*2;
//画柱形图
for ($i=0;$i<$num;$i++){
srand((double)microtime()*1000000);
if($this->R!=255 && $this->G!=255 && $this->B!=255){
$R=Rand($this->R,200);
$G=Rand($this->G,200);
$B=Rand($this->B,200);
}else{
$R=Rand(50,200);
$G=Rand(50,200);
$B=Rand(50,200);
}
$color=ImageColorAllocate($this->IMAGE,$R,$G,$B);
//柱形长度
$leight=($this->X-$this->BORDER*2)*($item_array[$i]/$item_max);
ImageFilledRectangle($this->IMAGE,$this->BORDER,$yy-$this->BORDER,$leight,$yy,$color);
ImageString($this->IMAGE,$this->FONTSIZE,$leight+2,$yy-$this->BORDER,$item_array[$i],$this->FONTCOLOR);
//用于间隔
$yy=$yy-$this->BORDER*2;
}
}

uuq 2004-08-09
  • 打赏
  • 举报
回复
不知道。不过倒有个控件可以。就是excel控件。
看下webEditor在线编辑器,里面有一个
内容概要:本文围绕城市场景下的无人机三维路径规划问题,提出了一种新颖的多目标粒子群优化算法(NMOPSO),旨在解决高维复杂环境路径规划面临的多重挑战。研究聚焦于导航变量的多目标优化,构建了一个包含路径长度、飞行安全性、能量消耗等多个相互冲突目标的优化模型,并采用改进的粒子群算法进行高效搜索,最终获得一组Pareto最优解集,为实际决策提供多样化路径选择方案。该方法结合Matlab代码实现,详细阐述了算法的设计机制、数学建模流程及仿真验证过程,充分展示了其在密集城市建筑环境有效规避障碍物、满足飞行动力学约束并实现多目标权衡的能力,具有较强的工程应用价值。; 适合人群:具备一定优化算法理论基础和Matlab编程能力,从事无人机路径规划、智能交通系统、自动化控制、人工智能应用等方向研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①应用于城市环境的无人机物流配送、巡检监控、应急救援等实际任务的三维路径规划;②为高维、非线性、多约束的多目标优化问题提供有效的算法设计思路与改进参考;③通过Matlab仿真平台复现算法,进一步开展性能测试、参数调优与算法对比研究,推动相关领域的技术创新。; 阅读建议:此资源强调算法原理与工程实践的深度融合,建议读者重点研读目标函数的构建方式、约束条件的处理策略以及NMOPSO算法的核心改进机制,并务必动手运行和调试所提供的Matlab代码,以深入理解算法在三维空间路径优化的具体实现细节与实际表现。
内容概要:本文档围绕基于10机39节点的电力系统仿真展开,依托Matlab/Simulink平台构建标准电力系统模型,系统性地实现了电力系统稳态与暂态过程的仿真分析。内容涵盖潮流计算、短路故障、暂态稳定性、N-k故障分析、蓄意攻击与级联故障模拟等核心问题,并引入混合整数线性规划(MILP)等优化方法进行电网脆弱性评估与关键故障筛选。文档突出科研复现导向,整合了状态估计、虚假数据注入攻击、优化算法等前沿技术的交叉应用,具有较强的理论深度与工程实践价值。; 适合人群:具备电力系统基本理论知识和Matlab/Simulink仿真能力的研究生、科研人员及电力工程技术人员,特别适用于从事电力系统稳定性分析、安全防护、故障演化机制与优化调度等领域研究的专业人士。; 使用场景及目标:① 掌握10机39节点系统的建模方法与仿真流程;② 学习并复现电力系统典型故障(如短路、N-k故障、级联故障)的建模与动态响应分析;③ 理解基于MILP的电网脆弱性评估、攻击策略建模与故障传播机制;④ 结合优化算法开展电力系统安全防御、恢复策略与韧性提升研究。; 阅读建议:建议结合文档标注的“顶级EI复现”“核心论文复现”等标签,重点关注模型构建逻辑与代码实现细节,优先运行仿真案例以理解其物理背景与数学建模原理,同时深入分析故障场景设定、目标函数设计及优化求解策略的工程意义与学术价值。

21,889

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧