ByteScout Spreadsheet SDK - C# - ShrinkToFit for Cells - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

ByteScout Spreadsheet SDK – C# – ShrinkToFit for Cells

  • Home
  • /
  • Articles
  • /
  • ByteScout Spreadsheet SDK – C# – ShrinkToFit for Cells

ByteScout Spreadsheet SDK – C# – ShrinkToFit for Cells

Program.cs

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")){
                File.Delete("Output.xls");
            }

            // Save document
            document.SaveAs("Output.xls");

            // Close Spreadsheet
            document.Close();

            // open generated XLS document in default program
            Process.Start("Output.xls");
        }
    }
}


  Click here to get your Free Trial version of the SDK

Tutorials:

prev
next