简体   繁体   English

传递值以仅打印,pdf预览或在excel中打开

[英]Passing Values to print only, pdf preview, or open in excel

I have two reports: Checklist and Location. 我有两个报告:清单和位置。 Depending on which report is chosen decides the action of the form of what path to take. 根据选择的报告来决定采取哪种路径形式的动作。 I also have a select that ask the user whether or not they want to print automatically, preview as a pdf, or open in excel. 我还可以选择询问用户是否要自动打印,以pdf格式预览或在excel中打开。

<select name="Format" required>
    <option selected value="">Select Format</option>
    <option value="print">Print</option>
    <option value="pdf">Preview</option>
    <option value="xls">Excel</option>
</select>

I am curious of how I am suppose to forward this information in order to do the queries and process the choice the user is requesting. 我很好奇我应该如何转发此信息以便进行查询并处理用户所请求的选择。 I am sure people do things like this all the time. 我确信人们总是在做这样的事情。 Would anyone like to share any examples or advice - stepping stones to get me on the right path? 有谁想分享任何例子或建议-踏脚石让我走上正确的道路? Thanks in advance! 提前致谢!

Tagged below are all the languages I am using that I could use to achieve this goal. 下面标记的是我正在使用的可以用于实现该目标的所有语言。

I have tried using pdfmake on my reports. 我尝试在报告中使用pdfmake。 It has the option to generate a report with Excel, Print, or download pdf. 它可以选择使用Excel,打印或下载pdf生成报告。 All you have to do is pass a json array. 您要做的就是传递一个json数组。 You can read the documentation on github. 您可以阅读github上的文档。 Here's the link: PDFMake 这是链接: PDFMake

This might not be the best answer but it would be a stepping stone for you. 这可能不是最好的答案,但对您来说将是一个垫脚石。

If you are just trying to send data to a different page, then you can use query parameters for that. 如果您只是尝试将数据发送到其他页面,则可以使用查询参数。 One option is to build the query parameters as users update the dropdown: 一种选择是在用户更新下拉列表时构建查询参数:

 var select = $('select[name=Format]'); function buildUrl(option) { return 'some/endpoint?option=' + option; } select.change(function() { var value = $(this).val(); var url = buildUrl(value); console.log('URL to call:', url); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <select name="Format" required> <option selected value="">Select Format</option> <option value="print">Print</option> <option value="pdf">Preview</option> <option value="xls">Excel</option> </select> 

and then you can use JavaScript or CF to detect the presence (or absence) of the query parameters to meet your app's requirements. 然后您可以使用JavaScript或CF检测是否存在查询参数,以满足您的应用程序要求。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM