spreadsheetlight

Get Names of all Columns in Excel sheet in SpreadSheetLight

五迷三道 提交于 2019-12-11 15:26:58
问题 I'm trying to populate a combobox with the names of the columns in a spreadsheet. I'm using the spreadsheetlight library. I can set the cell value using the following code where A refers to column name and 1 refers to row name. (Am I right?) But how can I get the the name of all columns in all sheets? SLDocument sl = new SLDocument(); sl.SetCellValue("A1", true); 回答1: First, get the last column index using SLWorksheetStatistics : SLWorksheetStatistics stats = sl.GetWorksheetStatistics(); int

What is the analogue to Excel Interop's Worksheet.UsedRange.Rows in Spreadsheet Light?

£可爱£侵袭症+ 提交于 2019-12-07 22:36:32
问题 Using Excel Interop, you can get the count of rows in use by a sheet like so: _xlSheet.UsedRange.Rows (where "_xlSheet" is an Excel.Worksheet). What is the equivalent in Spreadsheet Light? You can add a worksheet like so: var sl = new SLDocument(); . . . sl.AddWorksheet("SheetsToTheWind"); ...but how can you then access that worksheet to interrogate it for its used row count? 回答1: After adding the worksheet it is active as well. That means that you can get the WorksheetStatistics from the

Row count with SpreadsheetLight

一曲冷凌霜 提交于 2019-12-07 05:13:29
问题 I'm looking for a function similar to DataTable.Rows.Count that can be used with an SLDocument to find out how many rows have data in them. Is there something available in SpreadsheetLight? Any other methods of achieving this? -Brendan 回答1: SLWorksheetStatistics stats1 = firstdoc.GetWorksheetStatistics(); for (int j = 1; j < stats1.EndRowIndex; j++) { var value = firstdoc.GetCellValueAsString(0, j) ; } 来源: https://stackoverflow.com/questions/31325827/row-count-with-spreadsheetlight