Joomla 2.5自定义组件PDF / Excel导出

时间:2022-01-15 08:15:13

I created a custom component for Joomla 2.5. I have some views where the user selects several options and the system returns tables with data according to the parameters selection. My problem is that I'd like to export these tables in PDF/Excel format without having to reload the page. I would also like to export only tha data returned from the model and not any other element of the page.

我为Joomla 2.5创建了一个自定义组件。我有一些视图,用户选择几个选项,系统根据参数选择返回包含数据的表。我的问题是我想以PDF / Excel格式导出这些表而无需重新加载页面。我还想只导出从模型返回的数据而不是页面的任何其他元素。

One solution might be to create a new view that creates the pdf or the excel and load it for example into a hidden iframe (am I stupid?)

一种解决方案可能是创建一个创建pdf或excel的新视图,并将其加载到一个隐藏的iframe(我是傻吗?)

My problem is that I would like to have something resusable...

我的问题是我希望有一些可以重复使用的东西......

1 个解决方案

#1


0  

You can create a link on your site to download the excel like

您可以在您的网站上创建链接以下载excel

index.php?option=com_myawesomecomponent&task=pdf.download&catid=10

Your controller action can then set the correct headers as nicholas did on his akeeba release system to force the browser to download the data

然后您的控制器操作可以设置正确的标头,就像尼古拉斯在他的akeeba发布系统上所做的那样强制浏览器下载数据

https://github.com/akeeba/release-system/blob/development/component/frontend/models/downloads.php#L213

#1


0  

You can create a link on your site to download the excel like

您可以在您的网站上创建链接以下载excel

index.php?option=com_myawesomecomponent&task=pdf.download&catid=10

Your controller action can then set the correct headers as nicholas did on his akeeba release system to force the browser to download the data

然后您的控制器操作可以设置正确的标头,就像尼古拉斯在他的akeeba发布系统上所做的那样强制浏览器下载数据

https://github.com/akeeba/release-system/blob/development/component/frontend/models/downloads.php#L213