首页 > 系统相关 >Ubuntu install libxlsx

Ubuntu install libxlsx

时间:2023-05-30 10:23:07浏览次数:30  
标签:std count now chrono libxlsx time install Ubuntu include

Copy from https://libxlsxwriter.github.io/getting_started.html

1

sudo apt-get install libxslt-dev

2.

git clone https://github.com/jmcnamara/libxlsxwriter.git 

3.

cd libxlsxwriter
make

4.

cd cmake # Or another sub-directory.
cmake ..
cmake --build .

5.

sudo cp libxlsxwriter.so.5 /usr/lib/libxlsxwriter.so.5
#pragma once
#include <chrono>
#include <condition_variable>
#include <ctime>
#include <curl/curl.h>
#include <curl/easy.h>
#include <fstream>
#include <functional>
#include <future>
#include <iostream>
#include <iomanip>
#include <map>
#include <memory>
#include <mutex>
#include <random>
#include <stdio.h>
#include <string>
#include <uuid/uuid.h>
#include <vector>
#include "xlsxwriter.h"

std::string get_time_now(bool is_exact = false)
{
    std::chrono::time_point<std::chrono::high_resolution_clock> now = std::chrono::high_resolution_clock::now();
    time_t raw_time = std::chrono::high_resolution_clock::to_time_t(now);
    struct tm tm_info = *localtime(&raw_time);
    std::stringstream ss;
    ss << std::put_time(&tm_info, "%Y%m%d%H%M%S");
    if (is_exact)
    {
        std::chrono::seconds seconds = std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch());
        std::chrono::milliseconds mills = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch());
        std::chrono::microseconds micros = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch());
        std::chrono::nanoseconds nanos = std::chrono::duration_cast<std::chrono::nanoseconds>(now.time_since_epoch());
        std::uint64_t mills_count = mills.count() - seconds.count() * 1000;
        std::uint64_t micros_count = micros.count() - mills.count() * 1000;
        std::uint64_t nanos_count = nanos.count() - micros.count() * 1000;
        ss << "_" << std::setw(3) << std::setfill('0') << std::to_string(mills_count)
           << std::setw(3) << std::setfill('0') << std::to_string(micros_count)
           << std::setw(3) << std::setfill('0') << std::to_string(nanos_count);
    }
    return ss.str();
}

char *uuid_value = (char *)malloc(40);
char *get_uuid_value()
{
    uuid_t new_uuid;
    uuid_generate(new_uuid);
    uuid_unparse(new_uuid, uuid_value);
    return uuid_value;
}

void xlsxwriter_excel(const int &len)
{
    lxw_workbook *workbook = workbook_new("hello_world2.xlsx");

    lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
    worksheet_set_column(worksheet,0,0,50,NULL);

    // write header

    worksheet_write_string(worksheet, 0, 0, "Header", NULL);

    worksheet_write_string(worksheet, 0, 1, "Number", NULL);

    for(int row=1;row<=len;row++)
    {
        worksheet_write_string(worksheet,row,0,get_uuid_value(),NULL);
        worksheet_write_number(worksheet,row,1,row,NULL);
    }

    workbook_close(workbook);
    std::cout<<get_time_now(true)<<",finish in "<<__FUNCTION__<<std::endl;
}

int main(int agrs,char **argv)
{
    xlsxwriter_excel(atoi(argv[1]));
    return 0;
}

6.Compile

g++ -std=c++2a -I. *.cpp -o h1 -luuid -lpthread -lxlsxwriter

7.Run

./h1 1000000

 

 

标签:std,count,now,chrono,libxlsx,time,install,Ubuntu,include
From: https://www.cnblogs.com/Fred1987/p/17442487.html

相关文章

  • Rockchip RK3399 - 移植ubuntu根文件系统
    在上一篇文章中,我们介绍了通过busybox构建根文件系统,但是我们在使用的过程中有个致命的问题,就是缺少各种命令以及各种开发环境,比如python,jdk、mysql啊。比如我们需要使用python开发环境,那么我们就得自己去下载python源码编译,然后移植到开发板中。那我们就开始想,我们是不是像cento......
  • # yyds干货盘点 # 使用PyInstaller工具将Python程序打包成Mac可执行文件步骤
    大家好,我是皮皮。一、前言前几天在Python钻石群【JethroShen】问了一个Python打包的问题,这里拿出来给大家分享下。二、实现过程这里【eric】问了【ChatGPT】,并给出了代码,如下所示:在Mac系统中,Python程序不能直接打包成.exe可执行文件,因为.exe是Windows系统下的可执行文件格式,而Mac......
  • 使用PyInstaller工具将Python程序打包成Mac可执行文件步骤
    大家好,我是皮皮。一、前言前几天在Python钻石群【JethroShen】问了一个Python打包的问题,这里拿出来给大家分享下。二、实现过程这里【eric】问了【ChatGPT】,并给出了代码,如下所示:在Mac系统中,Python程序不能直接打包成.exe可执行文件,因为.exe是Windows系统下的可执行文件格......
  • 20、Ubuntu联网(NAT方式)
    一、配置NAT模式连接外网:然后打开VMware左上角‘编辑’-->‘虚拟网络设置’。可以看到NAT模式的名称是‘VMnet8’,点击一下这个模式,然后点击一下‘更改设置’。勾选‘NET模式’、‘将主机虚拟适配器连接带此网络’和‘使用本地DHCP服务将IP地址分配给虚拟机’,注意这个子网ip地......
  • can't not find Node.js binary ''path",make sure Node.js is installed and in your
    vscode中node执行debug报错报错信息如下 思路1:检查node是否安装成功win+R输入cmd  能够正常显示版本号,则证明没有问题,接着换个思路 思路2:根据提示打开图示的'launch.json'文件,在页面补充 runtimeExecutable具体补充什么内容呢?在overflow中找到了nginx中需要补......
  • ubuntu20.04固定ip
    1.编辑 01-network-manager-all.yaml 文件:1sudovim/etc/netplan/01-network-manager-all.yaml加入下面内容:1#LetNetworkManagermanagealldevicesonthissystem2network:3version:24renderer:NetworkManager5ethernets:6eno1:7......
  • Linux install vim errors All In One
    LinuxinstallvimerrorsAllInOneVimerrors❌RaspberryPi安装vim解压缩时候卡住了,手动中断了terminal,再次SSH连接时候,出现一下错误信息!pi@raspberrypi:~$sudoapt-getinstallvimE:无法获得锁/var/lib/dpkg/lock-frontend。锁正由进程11246(apt-get)持有......
  • Ubuntu下 git 报ssh key错误
    先贴错误:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@WARNING:POSSIBLEDNSSPOOFINGDETECTED!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@TheECDSAhostkeyforsh.gitlab.XXX.comhaschanged,andthekeyforthecorrespon......
  • ubuntu22安装docker、redis、mysql及部署net6应用
    一、更新系统软件包索引sudoaptupdate二、安装dockersudoaptinstalldocker.io三、在docker中安装Mysql拉取mysql镜像dockerpullmysql:latest查看镜像dockerimages运行容器dockerrun-itd-p3306:3306-eMYSQL_ROOT_PASSWORD=123456--namemysql......
  • Ubuntu20.04使终端用户名颜色高亮
    Ubuntu20.04使终端用户名颜色高亮问题背景你还在为你的Linux大量输出内容但是不能清晰的看到每次输入的命令而烦恼吗?找找下面图中的两条命令在哪......