简体   繁体   English

将 excel 工作表导出到 csv 中,同时省略带有公式但没有数据的底部行

[英]Export an excel sheet into csv while leaving out bottom rows with formulae but no data

I have an excel sheet (in a macros enabled excel file) that gets its data from other sheets.我有一个 excel 表(在启用宏的 excel 文件中)从其他表中获取数据。 If there is no data to be shown, the cell would be empty ("").如果没有要显示的数据,则单元格将为空 ("")。 But the formula will still be there of course.但当然,公式仍然存在。 Let's say SheetB gets data from SheetA, the formula in a cell on SheetB looks like this:假设 SheetB 从 SheetA 获取数据,SheetB 单元格中的公式如下所示:

=IF(SheetA,A2="","","data")

So when I export/convert the sheet as a CSV, all the rows with no data but formula also get exported.因此,当我将工作表导出/转换为 CSV 时,所有没有数据但公式的行也会被导出。 I tried copy pasting the contents of SheetB into SheetC as values.我尝试将 SheetB 的内容作为值复制粘贴到 SheetC 中。 I hoped that would get rid of the formulae.我希望这会摆脱公式。 Even when there's no formulae there's still some information in the cells which causes them to get exported.即使没有公式,单元格中仍然有一些信息导致它们被导出。

The only thing that works for me right now is to manually select and delete all the cells with no data but only formula.现在唯一对我有用的是手动 select 并删除所有没有数据但只有公式的单元格。 But it's time consuming as I have to do that to many files.但这很耗时,因为我必须对许多文件执行此操作。 And the number of rows with data differs from file to file.并且数据的行数因文件而异。 That's why I can't have a macro to delete rows after a specified row.这就是为什么我不能有一个宏来删除指定行之后的行。

I've tried searching for solution for over 3 hours.我已经尝试寻找解决方案超过 3 个小时。 I couldn't find anything.我什么也找不到。 I'm sorry for the noob question.我很抱歉这个菜鸟问题。

Use a helper column and calculate the LEN of that cell.使用辅助列并计算该单元格的 LEN。 If it's 0, it means is blank (even if there is a formula inside, it will return 0).如果为0,则表示为空(即使里面有公式,它也会返回0)。 Then you can filter, and export to csv only those rows where LEN is not 0然后您可以过滤并仅导出到 csv 那些 LEN 不为 0 的行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM