示例#1
0
        public void WorksheetColumnWidthTest()
        {
            MemoryStream        stream        = SpreadsheetReader.Create();
            SpreadsheetDocument doc           = SpreadsheetDocument.Open(stream, true);
            WorksheetPart       worksheetPart = SpreadsheetReader.GetWorksheetPartByName(doc, "Sheet1");

            WorksheetWriter writer = new WorksheetWriter(doc, worksheetPart);

            writer.FindColumn("A").Width = 20;
            writer.FindColumn(2).Width   = 20;
            writer.SetColumnWidth("C", 20);

            //Save to the memory stream, and then to a file
            SpreadsheetWriter.Save(doc);
            SpreadsheetWriter.StreamToFile(string.Format("{0}\\columnwidths.xlsx", GetOutputFolder()), stream);
        }
示例#2
0
        public void WorksheetColumnSplitTest()
        {
            MemoryStream        stream        = SpreadsheetReader.Copy(string.Format("{0}\\Templates\\columnstemplate.xlsx", Directory.GetCurrentDirectory()));
            SpreadsheetDocument doc           = SpreadsheetDocument.Open(stream, true);
            WorksheetPart       worksheetPart = SpreadsheetReader.GetWorksheetPartByName(doc, "Sheet1");

            WorksheetWriter writer = new WorksheetWriter(doc, worksheetPart);

            writer.FindColumn("C").Width = 20;

            //Save to the memory stream, and then to a file
            SpreadsheetWriter.Save(doc);
            SpreadsheetWriter.StreamToFile(string.Format("{0}\\columnsplit.xlsx", GetOutputFolder()), stream);
        }