我使用Filesaver.js和json-export-excel.js将 json 文件导出到 csv 。当逗号分隔符在字符串中看到逗号时,会导致列移动。
如何忽略字符串中的逗号?
<button ng-json-export-excel data="data" report-fields="{name: 'Name', quote: 'Quote'}" filename ="'famousQuote'" separator="," class="purple_btn btn">Export to Excel</button>
Run Code Online (Sandbox Code Playgroud)
JS文件:
$scope.data = [
{
name: "Jane Austen",
quote: "It isn\'t what we say or think that defines us, but what we do.",
},
{
name: "Stephen King",
quote: "Quiet people have the loudest minds.",
},
]
Run Code Online (Sandbox Code Playgroud)
当前 CSV 输出(不需要):(注意:|
标记 csv 文件中的列)
Name Quote
Jane Austen | It isn't what we say …
Run Code Online (Sandbox Code Playgroud) 我正在为函数 getNextPage() 编写单元测试。我设置了测试:expect(this.anotherService.resources).toEqual(3); 我收到错误:运行测试时预期未定义等于 3。我记录了 anotherService.resources,它在控制台中返回了 3。不知道为什么它不起作用。
测试
describe('Test for someController', function() {
beforeEach(function() {
module('someApp');
return inject(function($injector) {
var $controller;
var $q = $injector.get('$q');
this.rootScope = $injector.get('$rootScope');
$controller = $injector.get('$controller');
this.state = $injector.get('$state');
this.stateParams = {
id: 1,
}
this.location = $injector.get('$location')
this.timeout = $injector.get('$timeout')
this.upload = $injector.get('$upload')
this.someService = {
getItemList: function(res) {
var deferred = $q.defer();
deferred.resolve({
data: {
totalRows: 2,
rows: 3,
}
});
return deferred.promise;
},
pages: jasmine.createSpy(),
memberIds: 1,
currEng: []
};
this.anotherService = …
Run Code Online (Sandbox Code Playgroud)