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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Delete empty rows in a worksheet
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

GaussianFit

38 Posts

Posted - 12/03/2012 :  4:26:27 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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!

Penn

China
644 Posts

Posted - 12/03/2012 :  8:42:08 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

GaussianFit

38 Posts

Posted - 12/11/2012 :  5:14:33 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.
Go to Top of Page

Penn

China
644 Posts

Posted - 12/11/2012 :  10:04:30 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

GaussianFit

38 Posts

Posted - 12/23/2012 :  11:22:12 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000