Conver excel to bytes

i need to store a excel file into database as bytes

Hi,

Please see the following code, it illustrates how to save the workbook object into byte array.

C#


string filePath = @“F:\Shak-Data-RW\Downloads\source.xlsx”;


Workbook workbook = new Workbook(filePath);


//Save the workbook in memory stream

MemoryStream ms = new MemoryStream();

workbook.Save(ms, SaveFormat.Xlsx);


//Read bytes from memory stream

byte[] bytes = new byte[ms.Length];

ms.Read(bytes, 0, bytes.Length);

HI

I need a similar like mail merge option in Excel.In word we can use Mailmerge option to replace variables with values.similary in Excel Instead of PutValue() any option like mailmerge

Regards

Ajeesh

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

Please go through the following article and see if it is what you are looking for.
Smart Markers

hi

Thanks for giving the Smart Makers topic and it use full and i have another question is,how to format the cell like Percentage,Numeric.I should display only Percentage values or Numeric values in som cells so how to format the Template file accordingly

Regards

Ajeesh

Hi,

I think, that’s possible directly in smart markers.

However, I need to confirm and find it out. However, what you can do is that once your data has been inserted in your worksheet, then you can format them using Aspose.Cells APIs.

For data formatting, see the documents in the section:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/working-with-data-formatting.html

hi can you tell how to format excel directly using smart markers, that is i have template and in that template i have made format to each cell,according to that format my data should display like percentage,numeric and i don’t want to do any coding.Everything i need to do in template

Hi,


Well, you may format the cell(s) which contains Smart Marker(s) in the template file. E.g you have a smart marker in a cell i.e. &=DataSource.FieldName Now right click on the cell in MS Excel and click “Format Cells…”, now you can format the cell accordingly.

Thank you.