从一行复制格式到另一种使用C# [英] Copy format from one row to another using c#

查看:295
本文介绍了从一行复制格式到另一种使用C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这问题很相似,一问的此处。但给出的答案显示与数据一起复制格式。我有一个Excel工作表格式(.xlsx),我生成使用SSIS。现在,我已经设置在第一排的格式,这是我要复制到所有已填写工作表中的行。我怎样才能做到这一点使用C#?我使用Excel互操作。

This question is quite similar to the one asked here. But the answer given suggests copying the format along with the data. I have a excel sheet (.xlsx) that I generate using SSIS. Now I have set the formatting in first row, which I want to copy to all the rows that are already filled in the worksheet. How can I do that using C#? I am using Excel interop.

推荐答案

您可以使用的 PasteSpecial的 xlPasteFormats

Excel.Range R1 = (Excel.Range)oSheet.Cells[11, 11];
R1.Copy(Type.Missing);

Excel.Range R2 = (Excel.Range)oSheet.Cells[15, 15];
R2.PasteSpecial(Excel.XlPasteType.xlPasteFormats,
    Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, false, false);

这篇关于从一行复制格式到另一种使用C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆