Quantcast
Channel: NPOI
Viewing all articles
Browse latest Browse all 1621

New Post: Convert/Save HSSFWorkbook as XSSFWorkbook

$
0
0
public void SaveExcel()
    {
        try
        {
            FileStream fwriter = new FileStream("c:\\ss.xlsx",FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);

            MemoryStream file = new MemoryStream();
            workbook.Write(file);
            file.WriteTo(fwriter);

        }
        catch (Exception)
        {
            throw;
        }
    }
void InitializeWorkbook()
    {

        workbook = new HSSFWorkbook();

        ////create a entry of DocumentSummaryInformation
        DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation();
        dsi.Company = "NPOI Team";
        workbook.DocumentSummaryInformation = dsi;

        ////create a entry of SummaryInformation
        SummaryInformation si = PropertySetFactory.CreateSummaryInformation();
        si.Subject = "NPOI SDK Example";
        workbook.SummaryInformation = si;
        worksheet = workbook.CreateSheet("Sheet1");
    }

    public void AddData(int row, int col, string data)//, string format)
    {
        try
        {
            worksheet.CreateRow(row).CreateCell(col).SetCellValue(data);
        }
        catch (Exception)
        {
            throw;
        }
    }


Viewing all articles
Browse latest Browse all 1621

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>