帖子
帖子
用户
博客
课程
12
返回列表 发新帖
216
帖子
5
勋章
5911
Y币
zzhangqi 发表于 2021-10-26 09:49
你是用的安卓还是ios?测试代码能给我看看看吗

我测试安卓哦。
  1. <!DOCTYPE html>
  2. <html>

  3. <head>
  4.         <title>Module Develop</title>
  5.         <meta charset="utf-8">
  6.         <meta name="viewport"
  7.                 content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
  8.         <style type="text/css">
  9.                 html,
  10.                 body {
  11.                         height: 100%
  12.                 }

  13.                 body {
  14.                         background-color: #fff;
  15.                         margin: 0;
  16.                 }

  17.                 #wrap {
  18.                         height: 100%;
  19.                         position: relative;
  20.                 }

  21.                 #header {
  22.                         padding-top: 20px;
  23.                         background-color: #5082c2;
  24.                         height: 44px;
  25.                         position: relative;
  26.                 }

  27.                 #header h1 {
  28.                         font-size: 20px;
  29.                         height: 44px;
  30.                         line-height: 44px;
  31.                         margin: 0em;
  32.                         color: #fff;
  33.                         margin-left: 100px;
  34.                         margin-right: 100px;
  35.                         text-align: center;
  36.                 }

  37.                 #main {
  38.                         display: -webkit-box;
  39.                         -webkit-box-orient: vertical;
  40.                         -webkit-box-pack: center;
  41.                 }

  42.                 a.button {
  43.                         display: -webkit-box;
  44.                         -webkit-box-orient: vertical;
  45.                         -webkit-box-pack: center;
  46.                         -webkit-box-align: center;
  47.                         height: 32px;
  48.                         margin: 8px;
  49.                         background-color: rgba(240, 240, 240, 1.0);
  50.                         border-color: rgba(220, 220, 220, 1.0);
  51.                         border-width: 2px;
  52.                         border-style: solid;
  53.                 }

  54.                 a.active {
  55.                         background-color: rgba(240, 240, 240, 0.7);
  56.                 }
  57.         </style>
  58. </head>

  59. <body>
  60.         <div id="wrap">
  61.                 <div id="main">
  62.                         <br />
  63.                         <a class="button" tapmode="active" onclick="requestPermission()">权限动态申请(系统API)</a>
  64.                         <a class="button" tapmode="active" onclick="createWorkbook()">创建Workbook</a>
  65.                         <a class="button" tapmode="active" onclick="createSheet()">创建Sheet</a>
  66.                         <a class="button" tapmode="active" onclick="writeString1()">设置合并标题</a>
  67.                         <a class="button" tapmode="active" onclick="setColumnSize()">设置列宽</a>
  68.                         <a class="button" tapmode="active" onclick="writeString2()">设置Excel内容</a>
  69.                         <a class="button" tapmode="active" onclick="closeWorkbook()">关闭Workbook</a>
  70.                         <br />
  71.                 </div>
  72.         </div>
  73. </body>
  74. <script type="text/javascript">
  75.         var demo = null;
  76.         var fileName;
  77.         apiready = function () {
  78.                 demo = api.require('exportExcel');
  79.                 if (!demo) {
  80.                         alert("请添加模块后编译");
  81.                         return;
  82.                 }
  83.         }

  84.         function requestPermission() {
  85.                 api.requestPermission({
  86.                         list: ['storage'],
  87.                 }, function(ret, err) {
  88.                         api.alert({
  89.                                 msg: JSON.stringify(ret)
  90.                         });
  91.                 });
  92.         }

  93.         function createWorkbook() {
  94.                 fileName = 'fs://' + new Date().getTime() + '.xlsx';
  95.                 var ret = demo.createWorkbook({ fileName: fileName });
  96.                 alert(JSON.stringify(ret));
  97.         }

  98.         function createSheet() {
  99.                 var ret = demo.createSheet({ sheetName: 'Sheet1' });
  100.                 alert(JSON.stringify(ret));
  101.         }

  102.         function writeString1() {
  103.                 demo.writeString({
  104.                         row: 0,
  105.                         col: 0,
  106.                         data: '合并标题测试',
  107.                         style: {
  108.                                 textColor: 1,
  109.                                 fontSize: 20,
  110.                                 alignHorizontal: 1,
  111.                                 alignVertical: 2,
  112.                                 background: 9
  113.                         },
  114.                         merge: {
  115.                                 row: 0,
  116.                                 col: 9,
  117.                         }
  118.                 });

  119.                 alert('执行完成');
  120.         }

  121.         function setColumnSize() {
  122.                 for (var i = 0; i < 10; i++) {//列
  123.                         demo.setColumnSize({
  124.                                 col: i,
  125.                                 width: 20
  126.                         });
  127.                 }

  128.                 alert('执行完成');
  129.         }


  130.         function writeString2() {
  131.                 var row = 0;
  132.                 for (var i = 1; i < 100; i++) {//行
  133.                         row = i;

  134.                         for (var j = 0; j < 10; j++) {//列
  135.                                 demo.writeString({
  136.                                         row: row,
  137.                                         col: j,
  138.                                         data: '内容' + i,
  139.                                         style: {
  140.                                                 textColor: 9,
  141.                                                 fontSize: 20,
  142.                                                 alignHorizontal: 1,
  143.                                                 alignVertical: 2,
  144.                                                 borderArray: [{
  145.                                                         pointer: 4,//0:left 1:right 2:top 3:bottom 4:all
  146.                                                         lineStyle: 2
  147.                                                 }]
  148.                                         }
  149.                                 });
  150.                         }
  151.                 }
  152.                 alert('执行完成');
  153.         }

  154.         function closeWorkbook() {
  155.                 var ret = demo.closeWorkbook();
  156.                 alert(JSON.stringify(ret));
  157.         }

  158. </script>

  159. </html>
复制代码


11
帖子
0
勋章
292
Y币
3
帖子
0
勋章
24
Y币
正式包,导出的excel去哪个文件找,安卓手机上
216
帖子
5
勋章
5911
Y币
不是有fs路径么?自己定义fs文件位置。
晨曦星 · 2022-7-21 12:09正式包,导出的excel去哪个文件找,安卓手机上
12
您需要登录后才可以回帖 登录

本版积分规则