计算机怎样制作图表(用代码在excel里画一个机器人)

Ecxel是cbrother语言很早的一个模块,当时有开发者提了需求,本来是想封装xlnt库,奈何这个库使用起来总是有崩溃问题,于是就自己简单实现了一个,只实现了读取和修改单元格内容,想等xlnt库稳定一些再换过去。一晃两年过去了,最近又有开发者提出了修改样式的需求,就又看了一下xlnt库这两年的代码修改,发现修改量少的惊人,还是有崩溃问题,无奈又自己实现了样式部分,感觉再经过几次迭代升级,CBrother内置的excel库就要超越xlnt库了,到时候可以考虑把内置的excel库起个名字开源出去。

CBrother升级至v2.4.2
  • 主要是给excel模块添加了字体样式设置、边框样式设置、背景色设置、单元格尺寸设置以及合并单元格功能。
  • CBrother启动命令支持以当前工作目录位相对位置检索文件,比如命令行切换到d:/work目录,运行 cbrother.exe test/aa.cb 则实际运行了d:/work/test/aa.cb
  • mysql增加getResultColumnName接口,返回查询结果每一列的列名,组成一个Array
  • mysql和sqlite原upDate接口去除驼峰,修改为update。为了兼容老代码,老接口依然保留不再建议使用
  • windows版本窗口程序支持菜单栏和单选框,例子在sample\windows\winmenu.cb
  • import语句后如果书写分隔符';'也不再报错,之前版本import语句后是强制不能有分号的。这条是一名开发者在微信公众号私信和我沟通的,他初试cbrother写代码时因为import语句后写了分号,卡了半个小时,于是优化了下。新版本中import语句后的分号可有可无
  • 最后修复了一个崩溃的BUG,类二级子成员访问一个没有的方法时的崩溃问题,如:test.bbb.getString(),假如bbb类没有getString方法竟然崩溃了,查了代码是在抛异常的时候有一个变量手误写错了,也不知道是前几个版本改出问题还是一开始就手误了。
用代码在ecxel中用样式画一个机器人

计算机怎样制作图表(用代码在excel里画一个机器人)(1)

代码太长了,手机不好看下载新版本看 sample/excelrobot.cb

import lib/excel function main(parm) { var excel = new Excel(); var path = GetRoot() "excelrobot.xlsx"; var excelsheet = excel.addWorksheet("robot"); excelsheet.setColWidth("D",15); excelsheet.setColWidth("F",3); excelsheet.setColWidth("H",15); excelsheet.setRowHeight(5,81); excelsheet.setRowHeight(6,29); //head var cell = excelsheet.addCell("E6"); cell.set("."); cell.setFontBold(true); cell.setFontSize(36); cell.setAlignmentHorizontal(ALIGNMENT_HORIZONTAL_RIGHT); cell.setAlignmentVertical(ALIGNMENT_VERTICAL_TOP); cell.setBackgroundColor("00B050"); cell.setTopBorderColor("000000"); cell.setTopBorderStyle(BORDER_STYLE_THIN); cell.setLeftBorderStyle(BORDER_STYLE_THIN); cell = excelsheet.addCell("F6"); cell.set("_"); cell.setFontBold(true); cell.setFontSize(72); cell.setAlignmentHorizontal(ALIGNMENT_HORIZONTAL_CENTER); cell.setAlignmentVertical(ALIGNMENT_VERTICAL_BOTTOM); cell.setBackgroundColor("00B050"); cell.setTopBorderColor("000000"); cell.setTopBorderStyle(BORDER_STYLE_THIN); cell = excelsheet.addCell("G6"); cell.set("."); cell.setFontBold(true); cell.setFontSize(36); cell.setAlignmentVertical(ALIGNMENT_VERTICAL_TOP); cell.setBackgroundColor("00B050"); cell.setTopBorderColor("000000"); cell.setTopBorderStyle(BORDER_STYLE_THIN); cell.setRightBorderStyle(BORDER_STYLE_THIN); //arm var cell = excelsheet.addCell("B7"); cell.setBackgroundColor("92D050"); cell.setTopBorderColor("000000"); cell.setTopBorderStyle(BORDER_STYLE_THIN); cell.setLeftBorderStyle(BORDER_STYLE_THIN); cell = excelsheet.addCell("C7"); cell.setBackgroundColor("92D050"); cell.setTopBorderColor("000000"); cell.setTopBorderStyle(BORDER_STYLE_THIN); cell.setBottomBorderStyle(BORDER_STYLE_THIN); excelsheet.mergeCells("B8:B16"); cell = excelsheet.addCell("B8"); cell.setBackgroundColor("92D050"); cell.setLeftBorderColor("000000"); cell.setLeftBorderStyle(BORDER_STYLE_THIN); cell.setRightBorderStyle(BORDER_STYLE_THIN); cell = excelsheet.addCell("I7"); cell.setBackgroundColor("92D050"); cell.setTopBorderColor("000000"); cell.setTopBorderStyle(BORDER_STYLE_THIN); cell.setBottomBorderStyle(BORDER_STYLE_THIN); cell = excelsheet.addCell("J7"); cell.setBackgroundColor("92D050"); cell.setTopBorderColor("000000"); cell.setTopBorderStyle(BORDER_STYLE_THIN); cell.setRightBorderStyle(BORDER_STYLE_THIN); excelsheet.mergeCells("J8:J16"); cell = excelsheet.addCell("J8"); cell.setBackgroundColor("92D050"); for (var i = 8; i <= 16 ; i ) { cell = excelsheet.addCell("B" i); cell.setLeftBorderColor("000000"); cell.setLeftBorderStyle(BORDER_STYLE_THIN); cell.setRightBorderStyle(BORDER_STYLE_THIN); cell.setBottomBorderStyle(BORDER_STYLE_THIN); cell = excelsheet.addCell("J" i); cell.setLeftBorderColor("000000"); cell.setLeftBorderStyle(BORDER_STYLE_THIN); cell.setRightBorderStyle(BORDER_STYLE_THIN); cell.setBottomBorderStyle(BORDER_STYLE_THIN); } //body excelsheet.mergeCells("D7:H21"); cell = excelsheet.addCell("D7"); cell.set("CBrother"); cell.setFontSize(72); cell.setFontName("宋体"); cell.setFontColor("31869B"); cell.setBackgroundColor("00B0F0"); cell.setAlignmentHorizontal(ALIGNMENT_HORIZONTAL_CENTER); cell.setAlignmentVertical(ALIGNMENT_VERTICAL_CENTER); var arr = ["D","E","F","G","H"]; for (var i = 7; i <= 21 ; i ) { for (var j = 0; j < arr.size() ; j ) { cell = excelsheet.addCell(arr[j] i); cell.setLeftBorderColor("000000"); cell.setLeftBorderStyle(BORDER_STYLE_DOUBLE); cell.setRightBorderStyle(BORDER_STYLE_DOUBLE); cell.setTopBorderStyle(BORDER_STYLE_DOUBLE); cell.setBottomBorderStyle(BORDER_STYLE_DOUBLE); } } //leg excelsheet.mergeCells("E22:E31"); cell = excelsheet.addCell("E22"); cell.setBackgroundColor("FFFF00"); cell.setDiagonalBorderStyle(BORDER_STYLE_MEDIUM_DASHDOT); cell.setDiagonalBorderShow(true,false); excelsheet.mergeCells("G22:G31"); cell = excelsheet.addCell("G22"); cell.setBackgroundColor("FFFF00"); cell.setDiagonalBorderStyle(BORDER_STYLE_MEDIUM_DASHDOT); cell.setDiagonalBorderShow(false,true); for (var i = 22; i <= 31 ; i ) { cell = excelsheet.addCell("E" i); cell.setLeftBorderColor("000000"); cell.setLeftBorderStyle(BORDER_STYLE_MEDIUM_DASHDOT); cell.setRightBorderStyle(BORDER_STYLE_MEDIUM_DASHDOT); cell.setTopBorderStyle(BORDER_STYLE_MEDIUM_DASHDOT); cell.setBottomBorderStyle(BORDER_STYLE_MEDIUM_DASHDOT); cell = excelsheet.addCell("G" i); cell.setLeftBorderColor("000000"); cell.setLeftBorderStyle(BORDER_STYLE_MEDIUM_DASHDOT); cell.setRightBorderStyle(BORDER_STYLE_MEDIUM_DASHDOT); cell.setTopBorderStyle(BORDER_STYLE_MEDIUM_DASHDOT); cell.setBottomBorderStyle(BORDER_STYLE_MEDIUM_DASHDOT); } excel.save(path); }

,

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页