public static void Run() { string outputDirectory = Utils.GetOutputDirectoryPath(); string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.html"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_XLSX_WITH_PRINT_AREAS)) { HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat); options.SpreadsheetOptions = SpreadsheetOptions.ForRenderingPrintArea(); viewer.View(options); } Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}."); }
public static void Run() { string outputDirectory = Utils.GetOutputDirectoryPath(); string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.html"); int countRowsPerPage = 45; using (Viewer viewer = new Viewer(TestFiles.SAMPLE_XLSX)) { HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat); options.SpreadsheetOptions = SpreadsheetOptions.ForSplitSheetIntoPages(countRowsPerPage); viewer.View(options); } Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}."); }
public static void Run() { using (Viewer viewer = new Viewer(TestFiles.THREE_SHEETS)) { ViewInfoOptions viewInfoOptions = ViewInfoOptions.ForHtmlView(); viewInfoOptions.SpreadsheetOptions = SpreadsheetOptions.ForOnePagePerSheet(); ViewInfo viewInfo = viewer.GetViewInfo(viewInfoOptions); Console.WriteLine("Worksheets:"); foreach (Page page in viewInfo.Pages) { Console.WriteLine($" - Worksheet {page.Number} name '{page.Name}'"); } } }
private HtmlViewOptions CreateHtmlViewOptions(int passedPageNumber = -1, int newAngle = 0) { HtmlViewOptions htmlViewOptions = HtmlViewOptions.ForExternalResources( pageNumber => { string fileName = $"p{pageNumber}.html"; string cacheFilePath = this.cache.GetCacheFilePath(fileName); return(File.Create(cacheFilePath)); }, (pageNumber, resource) => { string fileName = $"p{pageNumber}_{resource.FileName}"; string cacheFilePath = this.cache.GetCacheFilePath(fileName); return(File.Create(cacheFilePath)); }, (pageNumber, resource) => { var urlPrefix = "/viewer/resources/" + Path.GetFileName(this.filePath).Replace(".", "_"); return($"{urlPrefix}/p{ pageNumber}_{ resource.FileName}"); }); htmlViewOptions.SpreadsheetOptions = SpreadsheetOptions.ForOnePagePerSheet(); htmlViewOptions.SpreadsheetOptions.TextOverflowMode = TextOverflowMode.HideText; htmlViewOptions.SpreadsheetOptions.RenderGridLines = globalConfiguration.GetViewerConfiguration().GetShowGridLines(); htmlViewOptions.SpreadsheetOptions.RenderHeadings = true; SetWatermarkOptions(htmlViewOptions); if (passedPageNumber >= 0 && newAngle != 0) { Rotation rotationAngle = GetRotationByAngle(newAngle); htmlViewOptions.RotatePage(passedPageNumber, rotationAngle); } return(htmlViewOptions); }