Tag: angularjs

如何使用Angular和Spring Rest服务下载xls文件?

我创build了一个angular度的工厂来调用spring rest服务来下载xls文件。 这是我的工厂: angular.module('app') .factory('SportsbookServiceCustom', function ($http) { return { exportToXLS: function () { return $http.get('api/sportsbooks/downloadXLS').then(function (response) { return response.data; }); } }; }); 我有这个代码为我的rest服务: @RequestMapping(value = "/sportsbooks/downloadXLS") public void downloadXLS(HttpServletResponse response) { Pageable pageable = new PageRequest(0, 20, Direction.ASC, "id"); Page<Sportsbook> page = sportsbookRepositoryCustom.findAll(pageable, null, null, null); List<Sportsbook> sportsbookList = page.getContent(); HSSFWorkbook workbook = […]

正确的方法将HTML表格导出为Excel文件?

将Excel表格导出为Excel文件的正确方法是什么,以便用户可以单击button并下载Excel文件(理想情况下使用Angular而不使用服务器)? 我见过很多这样的答案: 使用angularjs导出到xls,但是这样做会产生类似如下的错误: “文件格式和扩展名不匹配…文件可能被破坏…” 我相信该文件实际上是HTML或XML格式,而不是实际的Excel。 该警告不会给用户呈现良好的图像。 如何在不使用服务器的情况下将文件实际导出为Excel的正确方法是什么? 还是需要创build该文件的服务器?

如何parsing/读取已存在于服务器上的AngularJS中的excel文件(.xls或.xlsx)?

我是AngularJS的新手。 我有一个名为sample.xls的Excel文件已经存在于我的服务器上的某个文件夹中。 这个excel文件包含四张表格。 我想parsing整个文件(即所有表格中的数据)。 AngularJS应该怎么做? 我不希望代码上传一个Excel文件到AngularJS服务器。 我想要一种方法来parsing已经在服务器上使用AngularJS的Excel文件。 请有人帮我在这方面。 如果你可以把一些包含多个工作表的excel文件放在一个实例中来展示你的代码,那将会更好。 谢谢。

使用WebAPI / MVC下载Excel文件

我正试图通过WebAPI下载Excel文件。 基本上Excel文件是通过记忆stream在这篇文章的帮助下创build的 Excel Content正在生成,但是我无法下载Excel,因为当我在Chrome Network Tools的“响应”选项卡中看到响应时,响应本身就是纯XML。 以下是我的代码为C# var sheet = linq.ExportToExcel(userAddedList); var stream = new MemoryStream(); var sw = new StreamWriter(stream); sw.Write(sheet); sw.Flush(); var result = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(stream.GetBuffer()) }; result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = "Report.xml" }; result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/ms-excel"); var response = ResponseMessage(result); return response; 这就是我如何通过Angular调用它。 var […]

使用angularjs在MVC中上传Excel文件。 HttpPostedFileBase是空的

我正在尝试使用angular度js在mvc上传一个excel文件。 以下是我的观点代码: <div class="browsebtn" ng-controller = "serviceablectrlr"><input type="file" id="dataFile" name="uploadFile" data-max-size="2097152" accept=".xls, .xlsx" onclick="$('#fileError').hide();" /> </div> <input id="btnUploadExcel" type="button" value="Upload" ng-click="UploadConfirmation()" class="btn btn-yellow" /> 以下是我的控制器代码: var app = angular.module('ProductCatalog'); app.controller('serviceablectrlr', function ($scope, $http) { var apiURL = $("#ProductCatalogApiUrl").val(); var ClearFile = function () { $("#dataFile").val(''); } // pass file object and url to this method […]

如何将相同大小的图像从html表格导出到excel

我正在面对从HTML表格导出图像的一些问题。 当我点击导出button下载html表格作为excel文件。 下载的xls文件具有不同的图像大小。 我想导出图像的大小在HTML表中。 我正在使用下面的代码,请给出适当的build议。 任何其他build议也是有帮助的。 <style> table,th,td { border:2px solid red; border-collapse:collapse; } </style> </head> <body> <br/> <br/> <div id="divTable"> <center> <table> <caption>Person Information</caption> <tr> <th>Name</th> <th>Gender</th> <th>contact</th> <th>Image</th> </tr> <tr> <td rowspan="4"><img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ3rlUFLRgsZ9kWB2DHyelOZdsRn6vXm2HlXKULG5qfYQZVYSrClw" alt="Flowers in Chania" width="80px" height="80px"></td> <td >Male</td> <td>7665716415</td> <td>image</td> </tr> <tr> <td >Male</td> <td>7665716415</td> <td>image</td> </tr> <tr> <td >Male</td> <td>7665716415</td> […]

Google Blockly和AngularJS

我需要给一组高级用户一种创build和保存math公式的方法,稍后将作为购物车结账例程的一部分运行。 我必须承担的权力用途不是程序员,但可以遵循简单的指示。 公式不会经常改变,但必须在高级用户的控制之下,而不是系统pipe理员或程序员。 一个可视化的语言用户界面对于这种需求似乎是一个很好的匹配,一个高级用户可以涉及到的环境最终会生成JavaScript代码,检出程序将能够评估(myFormula)。 例如myFormula: 在这个例子中,费用被指定为… input type =“number”ng-model =“fee”,并且在退房时input总额(保存公式之前不包括testingfunction)。 …然后在一个单独的文本框中的公式看起来像下面(我假设费用保存在0.05。 var youPay = IF gross> 1000 THAN fee * gross ELSE 50 youPay结果将显示给结帐人员。 在这个例子中,如果毛额低于1000美元,则基本额度为50美元,否则他们将支付总额的5% 有没有人对Google Blockly项目或其他解决scheme有任何意见? 也许一个Excel到JavaScript的代码生成器,其中的Excel公式可以在保存在我的应用程序之前进行testing。 然后将有另一层这个解决scheme,需要确保公式不会造成安全问题或引入错误,可能会使检出应用程序崩溃。

使用ng-csv将HTML页面中的表格导出到Excel

我使用Yeoman Angular发生器做了一个简单的项目。 我从这个API做了一个表。 这是我的main.html: <div ng-controller="MainCtrl"> <button type="button" ng-csv="getArray" csv-header="getHeader()" filename="test.csv">Export</button> </div> <div class="row"> <div class="col-xs-12 table"> <table class="table table-striped"> <thead> <tr> <th>No.</th> <th>ID Pel.</th> <th>Cust ID</th> <th>Meter SN</th> <th>Readingpoint</th> <th>Last Dial</th> <th>Status</th> </tr> </thead> <tbody> <tr ng-repeat="pop in tableData"> <td>{{pop.No}}</td> <td>{{pop.idPel}}</td> <td>{{pop.custID}}</td> <td>{{pop.uSN}}</td> <td><a ui-sref="app.bill_detail3">{{pop.metername}}</a></td> <td>17-02-2015 | 16.00</td> <td><span class="label label-success">Online</span></td> </tr> </tbody> </table> […]

AngularJS / JAX-RS:如何获得正确的Excel文档响应

我想通过JAX-RS web服务导出Excel文件,然后从Web应用程序下载/打开它。 这听起来很有效,无论是从curl调用,还是从AngularJS v1.4.7前端调用。 我在Windows 7 Professional下使用Microsoft Excel 2013 64位。 在服务器端,web服务实现如下: @POST @Produces("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") @Consumes(MediaType.MULTIPART_FORM_DATA) @Path("/compare") public Response compare( @FormDataParam("controlFile") InputStream controlIs, @FormDataParam("controlFile") FormDataContentDisposition controlFileDetail, @FormDataParam("testFile") InputStream testIs, @FormDataParam("testFile") FormDataContentDisposition testFileDetail ) { //(…) //creating my Excel file using Apache POI SXSSFWorkbook File file = new File(reportFileName); ResponseBuilder responseBuilder = Response.ok((Object) file, MediaType.APPLICATION_OCTET_STREAM) .header("Access-Control-Allow-Origin", "*") .header("Content-Disposition", […]

在Angular js中导出到Excel

我在导出到Excel时遇到问题。 视图 <a ng-href="#"> <i class="fa fa-file-excel-o" ng-click="export_excel()"> Export to Excel</i> </a> <table class="table table-striped table-bordered table-hover table-checkable order-column" id="sample_1"> <thead> <tr> <th>Sl No</th> <th>Scope of Work</th> <th>Description</th> </tr> </thead> <tbody> <tr class="odd gradeX" ng-repeat="scpdata in scopeData"> <td>{{$index + 1}}</td> <td>{{scpdata.scope_of_work}}</td> <td>{{scpdata.ss_description}}</td> </tr> </tbody> </table> JS控制器 $scope.export_excel = (function() { var uri = 'data:application/vnd.ms-excel;base64,' , […]