How to import header and footer

Aspose.Cells allows to add headers and footer to the worksheets at runtime but it is recommended to set headers and footers manually in the pre-designed file for printing. You can use Microsoft Excel as a GUI tool to set headers and footers easily to reduce your efforts and development time. Aspose.Cells can import the file and reserve these settings.

Where can I find the info to import file for Aspose.Cells?

thanks

Charlie

Hi Charlie,

Thanks for considering Aspose.

Aspose.Cells can create spreadsheets (new excel files) from the scratch. The component is also well-versed to update an existing excel template files, you may easily load/import an excel template file with all the data, formulas, objects, formattings or other settings preserved, add/update data, formulas, objects, formattings in the file and Save / Save As… the file for your need. For loading an existing excel files with all its settings, you may use Workbook.Open() method. Please check the wiki topic for reference: Different Ways to Open Files|Documentation

Thank you.

This is for ASP.net application.

Can the other users access the same file if one user has already opened the file using workbook.Open()? The open file is on the client’s memory or server’s memory.

Thanks

Charlie

Hi,

Thanks for considering Aspose.

I think if different users concurrently opening the same file, it migh skip some request and may create some problems.

I think you try to implement threads and lock the file opening portion. On each request the user made to open the file, it will lock other requests for a very little time period. So in this way it will allow other and may not skip any request and all users can open the same file.

E.g.,

//Open template

workbook = new Workbook();

//Creating a file stream containing the Excel file to be opened

FileInfo f = new FileInfo(TemplatePath);

lock (f)

{

fstream = new FileStream(TemplatePath, FileMode.Open, FileAccess.Read, FileShare.Read);

workbook.Open(fstream);

}

Thank you.

How do I close the workbook after coping the workbook. Please see the code below.

thanks

charlie

Workbook templateWorkbook = new Workbook();

Workbook workbook = new Workbook();

string path = MapPath("..");

string tempFile = path + @"\Template\Template1.xls";

templateWorkbook.Open(tempFile);

// copy the template workbook to new workbook

workbook.Copy(templateWorkbook);

// after finish coping, I want to close the templateWorkbook right away but can't find the close method.

// what is the alternative?

.... do time comsuming tasks

workbook.Save("New.xls", FileFormatType.Default, SaveType.OpenInBrowser, this.Response);

Hi,

Well, Aspose.Cells is pure .Net component and it totally rely on garbage collector to release the resources related objects. It will automatically release the resources and eliminates the objects when it is not in use or it thinks it is appropriate to relaese. When you call Workbook.Save() method all the data, objects etc. related the spreadsheet will be null.

Thank you.