您的位置:首页 > 房产 > 建筑 > 页面设计常用的字体颜色有_企业局域网的规划与设计_如何实现网站的快速排名_上海谷歌优化

页面设计常用的字体颜色有_企业局域网的规划与设计_如何实现网站的快速排名_上海谷歌优化

2025/3/14 13:39:15 来源:https://blog.csdn.net/weixin_41415820/article/details/146230804  浏览:    关键词:页面设计常用的字体颜色有_企业局域网的规划与设计_如何实现网站的快速排名_上海谷歌优化
页面设计常用的字体颜色有_企业局域网的规划与设计_如何实现网站的快速排名_上海谷歌优化

import fs from 'fs';

import path from 'path';

import xl from "excel4node";

// 创建一个新的工作簿

const wb = new xl.Workbook();

// 添加一个工作表

const ws = wb.addWorksheet('Sheet 1');

// 指定要读取的文件夹路径

const directoryPath = 'G://测试'; // 替换为你的文件夹路径

let i = 1;

const putImg = (ws, file) => {

    ws.row(i).setHeight(200); // 设置每行的行高为50

    ws.column(i).setWidth(40);


 

    ws.addImage({

        path: 'G://测试//' + file,

        type: 'picture',

        position: {

            type: 'twoCellAnchor',

            from: {

                col: 1,

                colOff: 0,

                row: i,

                rowOff: 0,

            },

            to: {

                col: 2,

                colOff: 0,

                row: i + 1,

                rowOff: 0,

            },

        },

    });

    i++;

}

// 使用同步方法读取文件夹

try {

    const files = fs.readdirSync(directoryPath);

    files.forEach(file => {

        // 获取文件的完整路径

        const filePath = path.join(directoryPath, file);

        // 使用fs.statSync检查是文件还是目录

        const stats = fs.statSync(filePath);

        if (stats.isFile() && file.startsWith("1074118")) {

            console.log(`File: ${file}`);

            let name = file.split(".")[0]

            ws.cell(i,2).string(name)

            // 将图片放入excel

            putImg(ws, file)

           

        } else if (stats.isDirectory()) {

            // console.log(`Directory: ${file}`); // 你可以递归地读取子目录

        }

    });

    // 将工作簿保存到文件

    wb.write('document_with_image.xlsx', (err, stats) => {

        if (err) {

            console.error('出现错误:', err);

        } else {

            console.log('带有图片的Excel文档已创建');

        }

    });

} catch (err) {

    console.error(`Unable to scan directory: ${err}`);

}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com