We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Set a cell value with row and column index

Hi,

how can i set a cell value by using row and column index?

Kind regards

Dominik

@mullu

Thanks for using Aspose APIs.

Please see the following sample code, its comments, its output Excel file as well as screenshot for your needs. The code accesses two cells. One by cell name and other by cell’s row and column indices.

Please also see the reference article given below related to this topic for more help.

Download Link:
Output Excel File.zip (5.6 KB)

C#

//Create workbook
Workbook wb = new Workbook();

//Access first worksheet
Worksheet ws = wb.Worksheets[0];

//Access cell B2 by Name
Cell b2 = ws.Cells["B2"];
b2.PutValue("This is cell B2.");

//Access cell F9 by Row and Column Indices.
Cell f9 = ws.Cells[8, 5];
f9.PutValue("This is cell F9.");

//Save the output Excel file
wb.Save("output.xlsx");

Reference Article:

Screenshot:

Hello,

can you give me a sample how to insert a decimal value.

Thank you and kind regards

Dominik

@mullu,

Thanks for your query.

See the following sample code for your reference:
e.g
Sample code:

Workbook wb = new Workbook();
            Cells cell = wb.Worksheets[0].Cells;
            
            //Set decimal value.
            cell[0, 0].PutValue(123.3456);
                        
            //Set numbers formatting style to the cell in the format i.e.: #,##0.00 (This is optional)
            Style style = wb.CreateStyle();
            style.Number = 4;
            style.Font.IsBold = true;
            style.Font.Size = 9;
            cell[0, 0].SetStyle(style);
             
            wb.Save("e:\\test2\\out1.xlsx"); 

Hope, this helps a bit.

Thank you Amjad,

i started with this sample:

define variable wb as Aspose.Cells.Workbook.
wb = new Aspose.Cells.Workbook().

define variable cell as Aspose.Cells.Cells.
cell = wb:Worksheets[0]:Cells.

In the next step i cannot choose the method PutValue.

Do you have any idea?

Thank you in advance

Dominik

this code is working for char and int

define variable wb as Aspose.Cells.Workbook.
wb = new Aspose.Cells.Workbook().

define variable cell as Aspose.Cells.Cells.
cell = wb:Worksheets[0]:Cells.

def var worksheet as Aspose.Cells.Worksheet.
worksheet = wb:Worksheets[0].

worksheet:Cells[“A1”]:PutValue(10).
wb:Save(“r:\tstd.xlsx”).

Kr
Dominik

@mullu,

Good to know that your issue is sorted out. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Hi,
there one issue. How can i embed fonts other then the windows standard fonts in a pdf document?

Kr

Dominik

@mullu,

Please share the non-standard font files along with the Excel file which these fonts so that we can check if you want to embed fonts with ANSI encoding or some other fonts. We will provide our feedback after analysis.

AsposeKontFont.zip (94.5 KB)

i attached the Excel template and the two font files.

Thank you

Dominik

@mullu,

Thank you for providing the sample data. Could you please guide us to achieve this functionality using Excel? It will help us to produce such PDF using Excel and then provide assistance to perform same task using Aspose.Cells.

CreatePDF.zip (80.0 KB)

Hi,
i attached a zip file includinge the source code, the tamplate and a pdf- and xlsx output file.

Thank you
Dominik

@mullu,

Thank you for providing more information. We have investigated this issue in detail and observed that Aspose.Cells supports true type font (.ttf) files only. We are afraid that the fonts provided by you cannot be incorporated as per your requirements.

Please feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Hello,
can you please provide samples for setting duplex printing and paper bins?

Thank you in advance

Dominik

@mullu,

Well, your query seems out of context. I am afraid, these forums are specific to Aspose APIs and we help the users to resolve any issue if it occurs due to Aspose APIs (e.g Aspose.Cells for .NET). Please browse internet to search the relevant document/thread on how to accomplish the task:
e.g


https://www.codeproject.com/Questions/1073776/Duplex-Printing-in-csharp

If in any case, the query/issue is relevant to Aspose.Cells APIs, please provide us more details and samples, we will check it soon

Hi,
thank you for you quick response.

I want to set duplex printing with Aspose.Cells.

With Aspose.Words it was easy for me to realize that and also to set the paper bin to be used.

Is there a possible way to realize that with Aspose.Cells?

Kind regards

Dominik

@mullu,

Could you share the sample code using Aspose.Words APIs. We will check and try to provide the same using Aspose.Cells APIs.

Hi,

below you will find a short sample for duplex printing.

DEFINE VARIABLE vodotx AS Aspose.Words.Document.
DEFINE VARIABLE vodotxprintersettings AS System.Drawing.Printing.PrinterSettings.

vodotx = NEW Aspose.Words.Document(“d:\test.dotx”).
vodotxprintersettings = NEW System.Drawing.Printing.PrinterSettings().

vodotxprintersettings:Duplex = System.Drawing.Printing.Duplex:DEFAULT.
vodotx:Print(vodotxprintersettings, “testprinter”).

@mullu,

I think you may make use of WorkbookRender.ToPrinter() method for your needs:
e.g
Sample code:

//Create workbook object from source Excel file
            Workbook workbook = new Workbook("e:\\test2\\Book1.xlsx");

            System.Drawing.Printing.PrinterSettings printSettings = new System.Drawing.Printing.PrinterSettings();
            //specify your desired attributes for printer settings.
            //.....

            //Print workbook using WorkbookRender
            WorkbookRender wr = new WorkbookRender(workbook, new ImageOrPrintOptions());
            wr.ToPrinter(printSettings);

Hope, this helps a bit.

Super, thank you. That worked fine on Workbook Level.

How it has to be handled on Worksheet Level?