首页 \ 问答 \ 以编程方式更改excel行或列的高度(Programmatically alter an excel rows or columns heigh)

以编程方式更改excel行或列的高度(Programmatically alter an excel rows or columns heigh)

可能很容易。 如何更改行或列高度?

 xlApp = new Excel.Application();
 xlApp.Visible = true;
 xlApp.DisplayAlerts = false;
 Excel.Workbooks xlWorkBooks = xlApp.Workbooks;
 xlWorkBook = xlWorkBooks.Open(directoryPath + "\\" + fileName, 0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);

 xlWorkSheets = xlWorkBook.Worksheets; //Get all the sheets in the workbook
 xlWorkSheet = (Excel.Worksheet)xlWorkSheets.get_Item("Sheet1"); //Get the allready exists sheet
 Excel.Range range = xlWorkSheet.UsedRange;
 Excel.Range chartRange;

 int colCount = range.Columns.Count;
 int rowCount = range.Rows.Count;

  xlWorkSheet.Cells[rowCount + 5, 1] = "Name and surname";
  chartRange = xlWorkSheet.get_Range("a" + (rowCount + 5), "e" + (rowCount + 5));
  chartRange.Font.Bold = true;

 xlWorkBook.SaveAs(fileName, Excel.XlFileFormat.xlOpenXMLWorkbook, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
  xlWorkBook.Close(misValue, misValue, misValue);
  xlWorkSheet = null;
  xlWorkBook = null;
  xlApp.Quit();

  GC.WaitForPendingFinalizers();
  GC.Collect();
  GC.WaitForPendingFinalizers();
  GC.Collect();

尝试使用xlWorkSheet.UsedRange.EntireRow.Height = value; 但它不起作用。 autoFit()正在工作,但我想用我的价值。


Probably easy one. How can i change rows or column heigh?

 xlApp = new Excel.Application();
 xlApp.Visible = true;
 xlApp.DisplayAlerts = false;
 Excel.Workbooks xlWorkBooks = xlApp.Workbooks;
 xlWorkBook = xlWorkBooks.Open(directoryPath + "\\" + fileName, 0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);

 xlWorkSheets = xlWorkBook.Worksheets; //Get all the sheets in the workbook
 xlWorkSheet = (Excel.Worksheet)xlWorkSheets.get_Item("Sheet1"); //Get the allready exists sheet
 Excel.Range range = xlWorkSheet.UsedRange;
 Excel.Range chartRange;

 int colCount = range.Columns.Count;
 int rowCount = range.Rows.Count;

  xlWorkSheet.Cells[rowCount + 5, 1] = "Name and surname";
  chartRange = xlWorkSheet.get_Range("a" + (rowCount + 5), "e" + (rowCount + 5));
  chartRange.Font.Bold = true;

 xlWorkBook.SaveAs(fileName, Excel.XlFileFormat.xlOpenXMLWorkbook, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
  xlWorkBook.Close(misValue, misValue, misValue);
  xlWorkSheet = null;
  xlWorkBook = null;
  xlApp.Quit();

  GC.WaitForPendingFinalizers();
  GC.Collect();
  GC.WaitForPendingFinalizers();
  GC.Collect();

Try it with xlWorkSheet.UsedRange.EntireRow.Height = value; but it doesn't work. autoFit() is working but i would like to work with my value.


原文:https://stackoverflow.com/questions/9922720
更新时间:2022-01-16 11:01

最满意答案

您可以使用INFORMATION_SCHEMA,如下所示:

SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'Database Name'
AND TABLE_NAME = 'Table Name' and any condition you want...;

you can use INFORMATION_SCHEMA instead as following:

SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'Database Name'
AND TABLE_NAME = 'Table Name' and any condition you want...;

相关问答

更多
  • 嗯,首先它没有性能问题。 它就是这样,并且考虑到硬件和数据库结构的性能限制,它将尽可能地执行。 至于什么是有用的,它只是一种表达特定逻辑条件的方式。 Well, firstly it doesn't have a performance issue. It is what it is, and it will be executed as well as possible given the performance constraints of the hardware and database struc ...
  • 您可以使用INFORMATION_SCHEMA,如下所示: SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'Database Name' AND TABLE_NAME = 'Table Name' and any condition you want...; you can use INFORMATION_SCHEMA instead as following: SELECT * FROM INFORMATION_SCHEMA. ...
  • 在你的情况下,子查询的表orders1肯定是主键( order_id ),而表order_item1有相应的外键order_id 。 因此,Oracle将表order_item1转换为保留键的表 ,并且能够从外部delete语句中的此表中delete 。 关键保存表的概念在此塔希提文档链接中进一步解释。 如果你想找出被删除的东西,你可以这样做 这些是你的子查询中加入的表: create table tq84_orders1 ( id number primary key, col_1 ...
  • 也许是这样的 select c.id, c.name, a.id, a.street from Company c left join c.addresses a on a.addressStatusId = 1 在Querydsl query.from(c) .leftJoin(c.addresses, a) .on(a.addressStatusId.eq(1)) .list(c.id, c.name, a.id, a.street) Maybe like this s ...
  • 您可能不需要对此进行子查询。 分组可以为每个名称找到找到的和未找到的。 只需将“找到”添加到分组中,您将获得每个名称的两条记录,一条用于找到,另一条用于找不到。 您也不需要另外查询总数,只需添加找到的并且未找到。 SELECT SUBSTRING(lastname,1,1) AS lastinitial, (CASE WHEN found = 1 THEN 1 ELSE 0 END) AS found_val, COUNT(lastname) AS found_count FRO ...
  • 我认为这是你正在寻找的那个。 该查询使用子查询分别获取每个resultid的最新resultid并在表tblTraceOutput上tblTraceOutput 。 然后,子查询的结果与表tblTraceOutput ( 本身 )连接在一起,前提是它与子查询上的所有列匹配。 可能匹配的记录是最新记录。 SELECT a.*, b.* FROM tblResults a INNER JOIN tblTraceOutput b ON a.resultid = b. ...
  • 您无法比较结果中的行。 您可以做的最好是复制子查询,例如将其称为q1b,并将其连接到on q1.id - 1 = q1b.id上的q1 on q1.id - 1 = q1b.id ; 然后在那里有像q1b.something = x东西(虽然也可以在ON中) 临时表也有一些可能性; 但你仍然需要两个连接,或者可能在哪里工作的相关子查询。 ...如果存储在一个真正的TEMPORARY表中,而不仅仅是你之后删除的一些“虚拟”表,你需要两个副本。 您不能在同一查询中两次使用相同的TEMPORARY表。 You c ...
  • 如果您执行LEFT OUTER (或FULL OUTER )连接,那么在从子查询中提取的字段中Copyright为null的任何情况都能满足您的要求。 If you do a LEFT OUTER (or FULL OUTER) join, then any cases where Copyright is null in the field drawn from the subquery satisfy what you are looking for.

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)