سؤال

Is there a way to load formulas, values and maybe also cell formattings from a given datasource file, like an XML file or .xlsx file directly to SpreadsheetGear WorkbookView UI (WPF)?

For example, I would create an .xlsx file which acts as a data source and where cell A1 holds for example a formula "=A1+B1". Then, on initializing the UI I would read the file and that formula would be inserted straight onto the UI, without a need to write IRange.Formula="A1+B1" in a code-behind class.

هل كانت مفيدة؟

المحلول

SpreadsheetGear supports reading/writing/displaying workbooks using either of Excel's two major file formats--Excel 97-2003 (.xls) and Open XML (.xlsx or *.xlsm). See the SpreadsheetGear.FileFormat enum for more information.

Use the Factory.GetWorkbook() method to open a workbook from disk, then set your WorkbookView's ActiveWorkbook property to the IWorkbook object returned from Factory.GetWorkbook(...) to display it. There is also a WorkbookView.ActiveWorksheet if you need to specify a particular worksheet within the workbook to display. Example:

IWorkbook workbook = Factory.GetWorkbook(@"c:\path\to\workbook.xlsx");
worbookView.ActiveWorkbook = workbook;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top