现在,我必须像这样进行硬编码
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) 我尝试通过 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
文件上。
欢迎任何建议!
我正在使用 Mocha + Chai 和axios-mock-adapter来测试我的 axios 请求。它运行良好,但我不知道如何test headers
通过 axios-mock-adapter来使用 axios 并确保Authorization
它Content-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) 我在我的项目中使用exceljs和 Typescript。但writeBuffer()
函数返回ExcelJS.Buffer
而不是Buffer
类型。并且由于ExcelJS.Buffer
继承自ArrayBuffer
,转换ArrayBuffer
为Buffer
将破坏 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) 这有点奇怪,运行时我没有看到任何错误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) 我怎么能跑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) 我正在使用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) 我正在使用 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.