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

Free Support Forum - aspose.com

How to paste row data

Hi

I am using Aspose Grid for now, how can I paste a row of data in the worksheet?

Thank You.

Hi,

See the sample code on how you may copy/paste a whole row or range for GridDesktop control.

Dim sheet As Worksheet = GridDesktop1.Worksheets(0)
Dim range As CellRange = New CellRange(2, 0, 2, sheet.ColumnsCount - 1)
sheet.ClearSelection()
sheet.AddSelectedRange(range)

sheet.Cells(2, 3).Value = “23”
GridDesktop1.Copy()
sheet.SetFocusedCell(4, 0)
GridDesktop1.Paste()


Thank you.

Hi

I am abit confused over the Web worksheet and worksheet.
This is how I created the grid.

<agw:GridWeb ID=“gw1” runat=“server” Width=“100%”
ForceValidation=“False” Height=“200px” MaxRow=“3” MaxColumn=“4”>

</agw:GridWeb>

In code behind, I did this, and I successfully bind the data into the grid.

var _with = gw1.WebWorksheets[0];
_with.Cells.Clear();

_with.DataSource = dt;
_with.CreateAutoGenratedColumns();
_with.DataBind();

With my current example, how can I achieve the copy/paste? For the sample you given, I cant compile the first line :

Dim sheet As Worksheet = gw1.WebWorksheets(0)

The error return is

Cannot implicitly convert type ‘Aspose.Grid.Web.Data.WebWorksheet’ to ‘Aspose.Grid.Web.Worksheet’.

Thank You.

Hi,

The previous code was for GridDesktop and not for GridWeb control.

For GridWeb if you need to copy data from one row to other row, you may try to loop through the row cells and copy each value from a row cell to other row’ cell, e.g


_with.DataBind();

//Copy the third row data (in each cell) to 78th row
for (int i = 0; i <= _with.Cells.MaxColumn; i++)
{

_with.Cells[77, i].PutValue( _with.Cells[2, i].StringValue);

}


Thank you.

Hi


Actually there is 2 things I want to achieve.

First I want to copy a row of data from excel into the grid, secondly, I want to copy multiple rows of data from excel into the grid.
Is it possible to have a feature like this? Is Excel-like features.

Your solution seems like copy from the one row of the grid to the another row in the grid.

Thank You.

Hi,

Well, I am afraid, currently you may use CTRL + C to copy the data from the Excel worksheet cells and use CTRL+V but all the data would be pasted in a single cell.

I have logged your issue into our issue tracking system with an id: CELLSNET-20403. Once we have any update about it we will let you know.

Thank you.

Hi


Since it is not possible to achieve using Aspose Grid, how about Aspose.Cells?

Thanks.

Hi,

Well, Aspose.Cells is a library which does not have any interface. It is a powerful component used to manipulate and implement almost all the features that MS Excel (97-2010) provides.

For this case, Aspose.Cells can copy a row data (with its formatting/style) from an existing Excel workbook sheet to other workbook at runtime see the document for your reference, but since it does not provide any interface like GridWeb, so you have to save the file to disk or some location, then you may open the resultant file in MS Excel to view the changes. By the way, you may Response the generated Excel file to the client browser, and if the client has installed Ms Excel, you may open the file on the client browser on the fly.


In short, if you want to have a grid like control in WYSIWYG (visual/interactive) manner, you may use GridWeb control, otherwise, Aspose.Cells can suit your need.

Thank you.