Link Search Menu Expand Document

Set ShrinkToFit for Cells - C#

Spreadsheet SDK sample in C# demonstrating ‘Set ShrinkToFit for Cells’

using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using Bytescout.Spreadsheet;
using System.IO;

namespace HelloWorld
    class Program
        static void Main(string[] args)
            // Create new Spreadsheet
            Spreadsheet document = new Spreadsheet();

            // Add new worksheet
            Worksheet worksheet = document.Workbook.Worksheets.Add("HelloWorld");

            // Set cell value
            worksheet.Cell(0, 0).Value = "Very, very, very, very long text";

            // Shrink text
            worksheet.Cell(0, 0).ShrinkToFit = true;

            // delete output file if exists already
            if (File.Exists("Output.xls")){

            // Save document

            // Close Spreadsheet

            // open generated XLS document in default program

Download Source Code (.zip)

Return to the previous page Explore Spreadsheet SDK