惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Palo Alto Networks Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Schneier on Security
Engineering at Meta
Engineering at Meta
I
InfoQ
L
LangChain Blog
Cyberwarzone
Cyberwarzone
T
Tenable Blog
WordPress大学
WordPress大学
P
Privacy & Cybersecurity Law Blog
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Jina AI
Jina AI
C
CERT Recently Published Vulnerability Notes
Scott Helme
Scott Helme
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Last Watchdog
The Last Watchdog
Last Week in AI
Last Week in AI
Cloudbric
Cloudbric
S
SegmentFault 最新的问题
爱范儿
爱范儿
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 叶小钗
AI
AI
T
Tor Project blog
I
Intezer
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
N
News and Events Feed by Topic
Latest news
Latest news
S
Security Affairs
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog RSS Feed
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
S
Securelist

博客园 - 匡匡

Vue 父子组件通信方式 Vue: 组件扩展 WebClient 指定出口 IP IIS8 下 JS, CSS 等静态文件出现 500 错误 使用 ffmpeg 转换 mov 视频 使用 ildasm 和 ilasm 修改程序集的的引用信息 2020-01-08 工作日记:无题 .Net Core 程序集管理说明(加载) .NET CORE 动态加载 DLL 的问题 ASP.NET 后台 COOKIE 的设置 使用 sql server 默认跟踪分析执行的 SQL 语句 Nginx深入详解之upstream分配方式 使用 HttpWebRequest 类做 POST 请求没有应反 webpack 里的 import, exports 实现原理 使用 pdf.js 查看发票时,显示不了台头和印章的解决办法 Flex 布局里 input 宽度最小 150px 的问题, 浏览器 BUG? sweetalert 快速显示两个提示, 第二个显示不出的问题 加权轮询和加权随机算法 在 Docker 中部署 ASP.NET CORE 应用
使用像素单位设置 EXCEL 列宽或行高
匡匡 · 2018-11-23 · via 博客园 - 匡匡

在导出 Excel 的时候, 经常要需要给列设置宽度或给行设置高度, 在使用 NPOI 或 EppPlus 等组件进行操作的时候, 列宽和行高的单位都不是像素, 好像是英寸,具体是啥也说不清。

平常在使用单位时, 已经习惯使用像素了, 所以希望在 EXCEL 里设置列宽或行高时也使用像素。

之前在使用 Aspose.Cells 时, 发现这个组件有个 SetRowHeightPixel 方法, 可以使用像素设置行高, 于是使用反编译看了一下实现原理:

private static float GetDpiX()
{
    try
    {
        using (Bitmap image = new Bitmap(1, 1))
        {
            using (Graphics graphics = Graphics.FromImage(image))
            {
                return graphics.DpiX;
            }
        }
    }
    catch
    {
        return 72;
    }
}


public void SetRowHeightPixel(int row, int pixels)
{
    double height = (double)((float)pixels * 72f / (float)GetDpiX());
    this.SetRowHeight(row, height);
}