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

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

问题描述

这个问题非常类似于此处。但是给出的答案建议复制格式和数据。我有一个excel表(.xlsx),我使用SSIS生成。现在我已经将第一行中的格式设置,我想要复制到工作表中已经填充的所有行。如何使用C#?我正在使用Excel interop。

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天全站免登陆