小编Tra*_*Son的帖子

如何使用exceljs按名称获取单元格?

现在,我必须像这样进行硬编码

var cell = worksheet.getCell('A1');
Run Code Online (Sandbox Code Playgroud)

但我想按名称定义我的单元格data,并通过以下方式访问单元格:

var cell = worksheet.getCell('data');
Run Code Online (Sandbox Code Playgroud)

一只忙碌的猫

我怎样才能用 exceljs 做到这一点? 非常感谢!

注意:解决我的问题的唯一解决方案似乎是添加列/行标题并定义键,但我不想在我的代码中这样做:

worksheet.columns = [
  { header: 'Id', key: 'id', width: 10 }
];
Run Code Online (Sandbox Code Playgroud)

exceljs

7
推荐指数
2
解决办法
2万
查看次数

通过 Dockerfile 和 ODT 在 Window Container 中安装 office365

我尝试通过 Dockerfile 和 ODT(Office 部署工具)在 Window 容器内安装 excel(或 Office 365)。这是我的dockerfile

FROM mcr.microsoft.com/windows/servercore:ltsc2016

# Install Office deployment tool
ADD https://download.microsoft.com/download/2/7/A/27AF1BE6-DD20-4CB4-B154-EBAB8A7D4A7E/officedeploymenttool_11901-20022.exe C:/deploymenttool_autoextract.exe
RUN C:/deploymenttool_autoextract.exe /quiet /passive /extract:C:

COPY installconfig.xml C:

# Install Office
RUN C:/setup.exe /configure installconfig.xml

ENTRYPOINT powershell
Run Code Online (Sandbox Code Playgroud)

和我的安装文件installconfig.xml

FROM mcr.microsoft.com/windows/servercore:ltsc2016

# Install Office deployment tool
ADD https://download.microsoft.com/download/2/7/A/27AF1BE6-DD20-4CB4-B154-EBAB8A7D4A7E/officedeploymenttool_11901-20022.exe C:/deploymenttool_autoextract.exe
RUN C:/deploymenttool_autoextract.exe /quiet /passive /extract:C:

COPY installconfig.xml C:

# Install Office
RUN C:/setup.exe /configure installconfig.xml

ENTRYPOINT powershell
Run Code Online (Sandbox Code Playgroud)

建造集装箱在安装办公室耽搁了好几个小时。我认为问题出在我的installconfig.xml文件上。

欢迎任何建议!

在此输入图像描述

window ms-office office365 docker dockerfile

7
推荐指数
0
解决办法
1907
查看次数

测试 Axios 请求的标头

我正在使用 Mocha + Chai 和axios-mock-adapter来测试我的 axios 请求。它运行良好,但我不知道如何test headers通过 axios-mock-adapter来使用 axios 并确保AuthorizationContent-type是正确的!

export const uploadFile = (token: string, fileName: string, file: Buffer): Promise<string> => {
  return new Promise((resolve, reject): void => {
    const uploadFileURL = `xxxxx.com`;
    axios
      .put(uploadFileURL, file, {
        headers: {
          Authorization: `Bearer ${token}`,
          "Content-type": "application/x-www-form-urlencoded",
        },
      })
      .then((response): void => {
        resolve(response.data.id);
      })
      .catch((error: Error): void => {
        reject(error.message);
      });
  });
};
Run Code Online (Sandbox Code Playgroud)

这是我的测试功能

  describe("uploadFile", (): void => {
    let mockAxios: MockAdapter; …
Run Code Online (Sandbox Code Playgroud)

javascript node.js axios axios-mock-adapter

6
推荐指数
1
解决办法
3823
查看次数

ExcelJS的writeBuffer不返回Buffer类型

我在我的项目中使用exceljs和 Typescript。但writeBuffer()函数返回ExcelJS.Buffer而不是Buffer类型。并且由于ExcelJS.Buffer继承自ArrayBuffer,转换ArrayBufferBuffer将破坏 Excel 文件。有人有解决这个问题的办法吗?提前致谢!

declare interface Buffer extends ArrayBuffer { }
Run Code Online (Sandbox Code Playgroud)
let resultExcel: Buffer; // buffer
const tmpResultExcel: ExcelJS.Buffer = await tmpWorkBook.xlsx.writeBuffer(); // arraybuffer
resultExcel = Buffer.from(tmpResultExcel); // doesn't work well
Run Code Online (Sandbox Code Playgroud)

buffer node.js arraybuffer exceljs

6
推荐指数
2
解决办法
7553
查看次数

Dockerfile 中的“npm install”不会安装任何依赖项

这有点奇怪,运行时我没有看到任何错误docker-compose build,但是当我访问容器时,我没有看到node_modules文件夹,只package.json看到package-lock.json文件。我运行时的任何日志都docker-compose build正常显示。例如:

....
added 552 packages from 678 contributors and audited 4007 packages in 11.2s
found 0 vulnerabilities
....
Run Code Online (Sandbox Code Playgroud)

我的 Dockerfile:

FROM node:10

ENV APP_PATH /app
WORKDIR $APP_PATH

COPY ./app_front/package*.json ./

RUN npm install -g ts-node typescript
RUN npm install

COPY . .

EXPOSE 3000
CMD [ "npm", "run", "start" ]
Run Code Online (Sandbox Code Playgroud)

docker-compose归档

version: "3.5"
services:
    mysql:
        image: mysql:5.7
        container_name: racer_mysql
        restart: always
        environment:
          MYSQL_DATABASE: xxxx
          MYSQL_USER: "xxxx" …
Run Code Online (Sandbox Code Playgroud)

node.js npm docker docker-compose

4
推荐指数
1
解决办法
4090
查看次数

TypeORM:如何在 queryRunner 中运行 SELECT...FOR UPDATE?

我怎么能跑SELECT... FOR UPDATE进去queryRunner 呢?我看到queryRunner只能访问的TypeORM文档manager,我如何访问Repository锁定记录。例如queryRunner.getRepository(User).setLock("pessimistic_write").....

      console.log("----------------- START TRANSACTION -----------------");

      const queryRunner = connection.createQueryRunner();
      // establish real database connection using our new query runner
      await queryRunner.connect();

      await queryRunner.startTransaction();

      try {
        // `SELECT....FOR UPDATE`
        // Want to .setLock("pessimistic_write")


        // commit transaction now:
        await queryRunner.commitTransaction();
      } catch (err) {
        // since we have errors lets rollback changes we made
        await queryRunner.rollbackTransaction();
      } finally {
        // you need to release query runner which is manually created:
        await …
Run Code Online (Sandbox Code Playgroud)

typeorm

3
推荐指数
1
解决办法
6630
查看次数

无法使用 Microsoft.Office.Interop.Excel 加载文件或程序集“office,版本 = 15.0.0.0”

我正在使用Microsoft.Office.Interop.Excel将excel转换为pdf。但是当我启动 Excel 应用程序时,发生了这个错误。我已经在我的电脑上安装了Excel 2013。(我使用的是 VS2019,Window 10)。

我的 Excel 的位置在C\Program Files (x86)\Microsoft Office\Office 15\Excel.

无法加载文件或程序集“office,版本=15.0.0.0,文化=中性,PublicKeyToken=xxxxxxxxxxx”。该系统找不到指定的文件

欢迎任何建议!

这是我的代码:

using Microsoft.Office.Interop.Excel;
using System;
using System.Runtime.InteropServices;

namespace ExcelToPdf
{
    public class ExcelApplicationWrapper : IDisposable
    {
        public Application ExcelApplication { get; }

        public ExcelApplicationWrapper()
        {
            ExcelApplication = new Application(); // start excel application
        }

        public void Dispose()
        {
            // Each file I open is locked by the background EXCEL.exe until it is quitted
            ExcelApplication.Quit();
            Marshal.ReleaseComObject(ExcelApplication);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)
using …
Run Code Online (Sandbox Code Playgroud)

.net c# excel office-interop

2
推荐指数
1
解决办法
4295
查看次数

Microsoft Graph API 每日限制

我正在使用 Microsoft Graph API 将 excel 文件上传到 Onedrive 并将其转换为 PDF。我的服务流量很大,所以我想了解 Microsoft Graph API 的每日限制?我每天可以向 Microsoft Graph 发送多少个请求?

有人已经在 Stackoverflow 上询问过Throttling,但我不太确定 Daily Limitation API?

10 minutes - 10000 requests

1 day (1440 minutes) - 1440000 requests
Run Code Online (Sandbox Code Playgroud)

那是对的吗?

Throttling is done per user per app. The threshold is 10000 requests every 10 minutes.

Microsoft Graph API - 限制

microsoft-graph-api

0
推荐指数
1
解决办法
3162
查看次数