The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Delete empty rows in a worksheet

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
GaussianFit Posted - 12/03/2012 : 4:26:27 PM
Origin Ver. and Service Release (Select Help-->About Origin): 8.1 SR3
Operating System: Windows 7

A quick question to ask: after importing the data into a worksheet,
there are always some empty rows in it. I could manually delete these rows, but it didn't work for the case that the row number is less than 30. How to do this in Origin C? Should I use datarange class? A sample code would be helpful. Thanks for your help first!
4   L A T E S T    R E P L I E S    (Newest First)
GaussianFit Posted - 12/23/2012 : 11:22:12 PM
Turned out that actually there is no need to delete empty rows, as long as I extract the length of a column first and use it to set the number for loop operation. Anyway thanks for all the tips!

quote:
Originally posted by Penn

Hi,

Do you mean that you want to clear the data in the selected row? If so, you can delete this row first, and then insert an empty row in the same position. You can refer to these two methods, DeleteRow and InsertRow.

To get the selected rows in the worksheet, please try the GetSelectedRange method.

Penn

Penn Posted - 12/11/2012 : 10:04:30 PM
Hi,

Do you mean that you want to clear the data in the selected row? If so, you can delete this row first, and then insert an empty row in the same position. You can refer to these two methods, DeleteRow and InsertRow.

To get the selected rows in the worksheet, please try the GetSelectedRange method.

Penn
GaussianFit Posted - 12/11/2012 : 5:14:33 PM
quote:
Originally posted by Penn

Hi,

By default, worksheet will add rows automatically, which makes the situation you mentioned happens. You can select the menu Format: Worksheet to open the Worksheet Properties dialog, and then go to the Miscellaneous tab, and clear the Auto Add Rows check-box. Then you can try to delete the rows again. If you want to delete the empty rows by using Origin C, the first thing is also to clear this check-box. Please refer to the following code.

Tree tr;
tr.Root.Grid.AutoAddRows.nVal = 0;  // format setting for clearing the check-box
if(0 == wks.UpdateThemeIDs(tr.Root))
{
	wks.ApplyFormat(tr, true, true);  // apply the settings, wks is worksheet variable
	wks.SetSize(5, -1);  // set size of worksheet, 5 rows
}


Penn



Thanks you so much for the tips. Indeed removing the check box worked for manual removal of empty rows. In my C code, the function "DeleteRows" was used to conditionally remove certain selected rows. For example, if the worksheet has 50 rows to start with, after running "DeleteRows" to remove 20 selected rows, it's left with 30 rows with data and 20 empty rows. I'm not sure if I could remove these 20 empty rows by inserting the C code you gave.
Penn Posted - 12/03/2012 : 8:42:08 PM
Hi,

By default, worksheet will add rows automatically, which makes the situation you mentioned happens. You can select the menu Format: Worksheet to open the Worksheet Properties dialog, and then go to the Miscellaneous tab, and clear the Auto Add Rows check-box. Then you can try to delete the rows again. If you want to delete the empty rows by using Origin C, the first thing is also to clear this check-box. Please refer to the following code.

Tree tr;
tr.Root.Grid.AutoAddRows.nVal = 0;  // format setting for clearing the check-box
if(0 == wks.UpdateThemeIDs(tr.Root))
{
	wks.ApplyFormat(tr, true, true);  // apply the settings, wks is worksheet variable
	wks.SetSize(5, -1);  // set size of worksheet, 5 rows
}


Penn

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000