<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>sunus的博客</title>
    <link>https://blog.bccn.net/sunus</link>
    <description>sunus的博客 的最新20篇文章</description>
    <copyright>Copyright(C) BCCN.NET</copyright>
    <lastBuildDate>2026-06-18 21:20:38 +0800</lastBuildDate>
    <item>
      <title>lua读取xlsx表</title>
      <link>https://blog.bccn.net/sunus/68587</link>
      <description>因为要在Windows下用lua读xlsx表，找不到合适的，所以写个模块来用。
我用的是lua5.1，这个模块依赖zip和luaxml，都是lua for windows 5.1自带的。


open(xlsx文件名)		成功返回getCell/close函数，如出错，返回nil和出错信息
getCell(Sheet名, 单元格坐标)	成功返回单元格的值，不成功返回nil和出错信息
close()				关闭打开的xlsx文件
n2Time(数字)			将getCell取得的数字转换成年月日时分秒字符串，只支持1970年以后的日期
nextRow(单元格坐标，偏移量)	取...</description>
      <category>Lua</category>
      <author>sunus</author>
      <pubDate>2026-06-18 21:20:38 +0800</pubDate>
    </item>
    <item>
      <title>Lua奇技淫巧之三——取得程序的运行路径</title>
      <link>https://blog.bccn.net/sunus/67788</link>
      <description>WINDOWS下，想取得程序的运行路径可以这么做：
arg[0]:match('.*\\')</description>
      <category>Lua</category>
      <author>sunus</author>
      <pubDate>2022-01-25 17:15:04 +0800</pubDate>
    </item>
    <item>
      <title>Lua奇技淫巧之二——给Lua添加switch</title>
      <link>https://blog.bccn.net/sunus/66796</link>
      <description>
	Lua没有switch语句，我们就给它加一个：


	一、简单的switch：

function switch(SwitchVal)
	return function(SwitchTable)
		local ReFunc = SwitchTable[SwitchVal]
		if type(ReFunc) ~= "function" then
			ReFunc = SwitchTable[ReFunc] or SwitchTable.default
		end
		return ReFunc and ReFunc()
	end
end

优点是实...</description>
      <category>Lua</category>
      <author>sunus</author>
      <pubDate>2019-08-28 17:35:20 +0800</pubDate>
    </item>
    <item>
      <title>如何在Lua中取得本机名和本机IP地址</title>
      <link>https://blog.bccn.net/sunus/65403</link>
      <description>local socket = require('socket')
local MyHostName = socket.dns.gethostname()	--本机名
local MyIP = socket.dns.toip(MyHostName)	--本机IP
</description>
      <category>Lua</category>
      <author>sunus</author>
      <pubDate>2018-07-18 11:59:33 +0800</pubDate>
    </item>
    <item>
      <title>让lua for windows自带的SciTE更好的支持中文</title>
      <link>https://blog.bccn.net/sunus/65401</link>
      <description>lua for windows自带的那个SciTE对中文支持不怎么好，按下面的方法改一下就行了：
启动scite, 照下面的顺序点击菜单:Options, Open User Options file, 打开Sciteuser.properties

	code.page=936


	output.code.page=936


	character.set=134


	font.monospace=font:宋体,size:10


	font.base=font:宋体,size:10


	

保存，关闭</description>
      <category>Lua</category>
      <author>sunus</author>
      <pubDate>2018-07-17 11:41:55 +0800</pubDate>
    </item>
    <item>
      <title>如何在Lua中执行命令行命令时捕获返回内容/不显示命令行窗口</title>
      <link>https://blog.bccn.net/sunus/65277</link>
      <description>
	Lua中，我们一般用os.execute()执行命令行命令，此时会显示命令行窗口，并返回系统状态码。


	但我们有时需要捕获返回内容/不显示命令行窗口，则可以使用函数：io.popen()，这个函数也可以执行命令行命令，但是返回的是一个文件，同时不显示命令行窗口。


	例子：


local ts= io.popen('dir')
local s = ts:read("*all")
print(s)

</description>
      <category>Lua</category>
      <author>sunus</author>
      <pubDate>2018-05-11 10:52:04 +0800</pubDate>
    </item>
    <item>
      <title>【转】各种软件许可协议的区别</title>
      <link>https://blog.bccn.net/sunus/65186</link>
      <description>
	


	版权见水印
</description>
      <category>默认分类</category>
      <author>sunus</author>
      <pubDate>2018-04-03 15:01:08 +0800</pubDate>
    </item>
    <item>
      <title>Lua使用luacom模块操作EXCEL之二——设置框线、颜色等</title>
      <link>https://blog.bccn.net/sunus/65185</link>
      <description>require 'luacom'
local excel = luacom . CreateObject( 'Excel.Application' )
excel . Visible = true
local book = excel . Workbooks:Add()
local sheet = book . Worksheets( 1 )
sheet . Name = 'gty'
local range = sheet:Range( 'A1:A10' )
local cell = sheet . Cells( 1 , 1 )
sheet:Range( 'D3:D6' ...</description>
      <category>Lua</category>
      <author>sunus</author>
      <pubDate>2018-04-03 14:53:41 +0800</pubDate>
    </item>
    <item>
      <title>Lua使用luacom模块操作EXCEL</title>
      <link>https://blog.bccn.net/sunus/65184</link>
      <description>--导入luacom模块
require('luacom')
require('lfs')    --导入lfs模块用于取得当前路径，和操作EXCEL无关
local sMainPath = lfs.currentdir()    --取得当前路径 

--创建EXCEL对象
MyExcel = luacom.CreateObject("Excel.Application")    --创建EXCEL对象
--MyExcel = luacom.CreateObject("Ket.Application")    --创建WPS表格对象，新版的WPS已经兼容了MSO，就不用这...</description>
      <category>Lua</category>
      <author>sunus</author>
      <pubDate>2018-04-03 14:45:19 +0800</pubDate>
    </item>
    <item>
      <title>Lua奇技淫巧之一——模拟Pascal中的with</title>
      <link>https://blog.bccn.net/sunus/65170</link>
      <description>
	Pascal(Delphi)、VB中都有一个with关键字，可以帮助程序员减少大量的输入、提高效率。Lua 中没有这个关键字，但我们可以利用以下方式模拟。&amp;nbsp;


	例：

a={}
setfenv(function()
    a=1
    b=2
end,a)()

	以上代码效果等于:

a.a=1
a.b=2

	等价于Pascal中的：

with a do
  begin
    a:=1;
    b:=2;
  end;

	当然，这样只能用于赋值，如果需要在a{}中写函数就不能这么写了。这时可以这样写：
...</description>
      <category>Lua</category>
      <author>sunus</author>
      <pubDate>2018-03-29 12:01:31 +0800</pubDate>
    </item>
    <item>
      <title>欧拉筛求素数，果然非常快</title>
      <link>https://blog.bccn.net/sunus/65154</link>
      <description>
	看到一个求素数的题目，忽然想试试欧拉筛有多快。


	题目：求一千万内素数的个数。


	先看最普通的筛子：1077秒

T = os.time()

--求iMaxN内的素数
local iMaxN = 10000000

--普通筛子
local iSS = {}	--素数数组
local iSZ = {}	--筛子
for i = 1, iMaxN do
	iSZ[i] = i
end

--过筛求出所有素数
for i = 2, math.sqrt(iMaxN) do
	for j = i + 1, iMaxN do
		if ...</description>
      <category>Lua</category>
      <author>sunus</author>
      <pubDate>2018-03-23 16:54:12 +0800</pubDate>
    </item>
    <item>
      <title>用TCC在Windows下编译Lua5.3.4</title>
      <link>https://blog.bccn.net/sunus/65153</link>
      <description>
	最新的Lua版本是5.3.4，网上能找到的编译过的版本有这么几种：


	1、Lua5.3.4源码


	2、用新版MinGW-w32/w64编译的Lua5.3.4，只有exe文件，没有链接库，同时MinGW必须带上libgcc_s_dw2-1.dll这么一个库，用起来比较麻烦


	3、用TCC编译并压缩过的Lua5.3.4，只有64K大，但也没链接库 


	因此，我想重新编译源码，生成动态/静态链接库及exe文件。因为最近在学习TCC，而TCC是是标准的C99，所以试着用TCC（0.9.27）来编译。以下默认TCC已经安装好（其实就是解压TCC到某个文...</description>
      <category>Tiny C</category>
      <author>sunus</author>
      <pubDate>2018-03-23 15:04:11 +0800</pubDate>
    </item>
  </channel>
</rss>
