Skip to main content

Пример использования функций для работы с файлами

Пример использования функций работы с файлами надстройки:


function CommandsProvider.readFileContent(context)
context.doWithDocument(function(document)
local file = openBundledFile("hello.txt")
local content = file:read("*a")
file:close()

copyBundledFile("hello.txt", "data/hello.txt", "ignore")

local out = io.open(getWorkingDirectory() .. "/data/hello.txt", "rb")
local outContent = out:read("*a")
out:close()

local sheet = document:getBlocks():getTable(0)
local cell = sheet:getCell(DocumentAPI.CellPosition(0, 0))
cell:setText(content .. outContent)
end)
end