在使用宏将 csv 加载到多个工作表中之前检查 csv 的列数
我有一个包含 3 个工作表的工作簿。我想将单个分段 csv 加载到多个工作表中,但在加载 csv 之前,我需要进行列计数检查以确保加载正确的 csv。
csv 将如下所示:
#3GMACRO,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,
IMSI,IMEI,Date,Time,UMTS MACRO-PARAMNAME,UMTS MACRO-UARFCNDL,UMTS MACRO- PrimaryScramblingCode,UMTS MACRO-CPICHTxPower,UMTS MACRO-PLMNCellId,UMTS MACRO- RNCId,UMTS MACRO-MCC,UMTS MACRO-MNC,UMTS MACRO - LAC,UMTS MACRO - RAC,UMTS MACRO - MaxUETxPower,UMTS MACRO - MeasuredRSCP
208101386528204,357539010035240,20100107,160000,macro1_param,10662,11,-99,268435456,0,0,1,1,0,0,-74
#3GFEMTO,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,
IMSI,IMEI,Date,Time,UMTS FEMTOS-PARAMNAME,UMTS FEMTOS-UARFCNDL,UMTS FEMTOS- PrimaryScramblingCode,UMTS FEMTOS-CPICHTxPower,UMTS FEMTOS-PLMNCellId,UMTS FEMTOS-RNCId,UMTS FEMTOS-MCC,UMTS FEMTOS-MNC,UMTS FEMTOS-LAC,UMTS FEMTOS-RAC,UMTS FEMTOS-MaxUETxPower,UMTS FEMTOS- MeasuredRSCP
208101386528204,357539010035240,20100107,160000,macro1_param,10687,252,-24,61,0,610,3956,486,11,5,-102
#2GMACRO,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,
IMSI,IMEI,Date,Time,GSM MACRO-PARAMNAME,GSM MACRO_CellID,GSM MACRO-MCC,GSM MACRO-MNC,GSM MACRO-LAC,GSM MACRO-RAC,GSM MACRO-Max permitted UE Tx power (SIB3),GSM MACRO-Measure RSSI
208101386528204,357539010035240,20100107,160000,macro1_param,GSM_Cell_Id=1,2,3,4,5,6,7
每个标题均为 IMSI、IMEI、日期、时间......。
会发生的情况是,当用户单击加载按钮时,它将将此分段的 csv 加载到 3 个不同的工作表中,如下所示,但我想要的是在加载 csv 之前,我应该在加载 csv 之前同时检查所有三个工作表中的列数这是需要的,因为如果完成列计数,用户就无法加载错误的 csv 文件。如果他加载了错误的 csv 文件,那么我们可以说选择了无效的 csv。我想要这个概念。
提前致谢,
I have an workbook with 3 worksheets.I want to load the a single sectionedwise csv to the multiple worksheets but before loading the csv I need to do the column count check to ensure that correct csv is loaded.
the csv will be as follows :
#3GMACRO,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,
IMSI,IMEI,Date,Time,UMTS MACRO-PARAMNAME,UMTS MACRO-UARFCNDL,UMTS MACRO- PrimaryScramblingCode,UMTS MACRO-CPICHTxPower,UMTS MACRO-PLMNCellId,UMTS MACRO- RNCId,UMTS MACRO-MCC,UMTS MACRO-MNC,UMTS MACRO - LAC,UMTS MACRO - RAC,UMTS MACRO - MaxUETxPower,UMTS MACRO - MeasuredRSCP
208101386528204,357539010035240,20100107,160000,macro1_param,10662,11,-99,268435456,0,0,1,1,0,0,-74
#3GFEMTO,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,
IMSI,IMEI,Date,Time,UMTS FEMTOS-PARAMNAME,UMTS FEMTOS-UARFCNDL,UMTS FEMTOS- PrimaryScramblingCode,UMTS FEMTOS-CPICHTxPower,UMTS FEMTOS-PLMNCellId,UMTS FEMTOS-RNCId,UMTS FEMTOS-MCC,UMTS FEMTOS-MNC,UMTS FEMTOS-LAC,UMTS FEMTOS-RAC,UMTS FEMTOS-MaxUETxPower,UMTS FEMTOS- MeasuredRSCP
208101386528204,357539010035240,20100107,160000,macro1_param,10687,252,-24,61,0,610,3956,486,11,5,-102
#2GMACRO,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,
IMSI,IMEI,Date,Time,GSM MACRO-PARAMNAME,GSM MACRO_CellID,GSM MACRO-MCC,GSM MACRO-MNC,GSM MACRO-LAC,GSM MACRO-RAC,GSM MACRO-Max permitted UE Tx power (SIB3),GSM MACRO-Measure RSSI
208101386528204,357539010035240,20100107,160000,macro1_param,GSM_Cell_Id=1,2,3,4,5,6,7
The header are IMSI,IMEI,Date,Time......... in each.
what will happen is when the user click the load button it will load this sectioned csv into 3 different worksheets as shown below, but what i want is before loading the csv i should check the column count in all three worksheets each simultaneously before loading the csv in each sheets.This is needed because if the column count is done so that the user cannot load the wrong csv file.If he loads the wrong csv file then we can say like invalid csv chosen.I wanted in this concept.
Thanks in advance,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 VBA 和普通文件 I/O 来检查文件,但我要做的是将其加载到隐藏工作表中,验证它,然后将数据从隐藏工作表复制到用户可见工作表。
如果有用的话,这还为您提供了重新组织演示文稿的机会。
You could use VBA and ordinary file I/O to inspect the file, but what I'd do is load it into a hidden sheet, verify it, then copy the data from the hidden sheet to the user-visible sheet.
This also gives you an opportunity to reorganize the presentation if that's useful.