We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

sheet.FirstVisibleColumn

Hi,

I import data from a datatable with 20 fields. The sheet should only show a range of the fields. So I use the commands:
sheet.FirstVisibleColumn = 2
sheet.LeftVisibleColumn = 8
but nothing happened.

When I create a PDF, with the same data the commands:
format.StartColumnIndex = 2
format.EndColumnIndex = 10
work fine. So what is the difference?

Thanks

3 Replies

GM Geetha M Syncfusion Team October 2, 2009 06:53 AM UTC

Hi Erich,

Thank you for your interest in Syncfusion products.

It is not possible to select data from the datatable to import. If you want to hide the columns before 2 and after 8, please refer to the code snippet given below:

List visible = new List();

// Add visible column index
for (int i = 2; i < 9; i++)
visible.Add(i);

int col = sheet.UsedRange.LastColumn;
//Hide other column
for (int i = 1; i < col + 1; i++)
{
if(!visible.Contains(i))
sheet.ShowColumn(i, false);
}

Please try this and let me know if you have any questions.

Regards,
Geetha


ES Erich Schneider October 5, 2009 01:34 PM UTC

Hi Geetha,

can you please explain me the usage of sheet.FirstVisibleColumn. I can't understand the difference to the PDF-Funnction StartColumnIndex.

Here my VB-Code of both

PDF:
ta.Fill(dataTable, kurzzeichen, kurzzeichen,
p_jahrLabel.Text, p_monatLabel.Text, Profile.mandid,
Profile.periid, False, Profile.benutzer)

table.DataSource = dataTable

format.StartColumnIndex = 2
format.EndColumnIndex = 10

table.Draw(page, rect, format)

XlsIO:
ta.Fill(dataTable, p_kurzvonLabel.Text, p_kurzbisLabel.Text,
p_jahrLabel.Text, p_monatLabel.Text, Profile.mandid,
Profile.periid, False, Profile.benutzer)

sheet.ImportDataTable(dataTable, True, 1, 1)
sheet.FirstVisibleColumn = 2
sheet.LeftVisibleColumn = 8



When I use
sheet.ShowColumn(1, False)
sheet.ShowColumn(11, False)
sheet.ShowColumn(12, False)
the columns are hidden, but still there.

Thanks





GM Geetha M Syncfusion Team October 8, 2009 06:07 AM UTC

Hi Erich,

FirstVisibleColumn and LeftVisibleColumn are used to Select / Highlight a cell in the worksheet. You may check our class reference in the link below which could give you more details.

IWorksheet Members

As you said, the column can be show / hide using the ShowColumn method. If you do not want the data in the sheet and like to delete them permanently, you may make use of sheet.DeleteColumn() method.

Please try this and let me know if you have any questions.

Regards,
Geetha


Loader.
Live Chat Icon For mobile
Up arrow icon