Example #1
0
        public static Excel.Worksheet Spread(this Excel.Worksheet sheet, IJsonToken jsonToken, string sheetName = null)
        {
            Globals.ThisAddIn.Application.ScreenUpdating = false;

            sheet.Name = (sheetName ?? jsonToken.Path()).ConvertSheetName();
            jsonToken.Spread(sheet);
            sheet.Change += jsonToken.OnChangeValue;
            //sheet.Protect();

            Globals.ThisAddIn.Application.ScreenUpdating = true;
            return(sheet);
        }
Example #2
0
        public static Excel.Workbook SpreadJsonToken(this Excel.Workbook book, Excel.Worksheet currentSheet, IJsonToken jsonToken)
        {
            var sheetName = jsonToken.Path().ConvertSheetName();

            if (book.SheetList().Any(x => x.Name == sheetName))
            {
                Excel.Worksheet sht = book.Sheets[sheetName];
                sht.Activate();
            }
            else
            {
                Excel.Worksheet sheet = book.Sheets.Add(After: currentSheet);
                sheet.Spread(jsonToken);
            }
            return(book);
        }