Copying data from Excel to Notepad

Hi,
I want to go to excel → ctrl+A ->ctrl + C → paste it into notepad.

The result has to be exact identical as to what human actions for above mentioned activity would do.
The BOT should:

  1. No “comma” as cell delimiter after pasting into notepad ;
  2. The gaps should be there in exact format.

Thanks :slight_smile:

@Bhanu_Rathore Hello ,you can read range , output data table as string using the output data table activity and in an assign use string.replace method to remove all comma delimiters from the generated string , then write the string to the text file.

Hi @MasterOfLogic
This is not working for me. Is there any other method ?

@Bhanu_Rathore hi, what challenge are you having using the method

Please see the attached file:
Sequence34.xaml (6.1 KB)

InputTable.xlsx (8.6 KB)

OutResult.txt (65 Bytes)

Hi @Dawodm

This is the OutPut I need : OutPut I Need.txt (90 Bytes)

I need the exact outlay when we copy paste data manually.

Hi @MasterOfLogic

I tried this method but the portal where I am supposed to upload the file is not accepting it after following the above method.

I just need raw: Copy and Paste! Simple (without replacing)

If possible can you share a xaml file here, so that i can check if it is working.
(It did’nt work last time when I built that logic)

Here is the solution. You need to import Excel Package to your Studio.
Microsoft.Office.Interop.Excel

I set it as Range for A1 to C5. You can modify it as you like.

Sequence38.xaml (5.9 KB)

Here is the result:

image

Best regards
Mahmoud

Hi @Dawodm

Its working :slight_smile: Thanks a lot. Could you just tell me how to paste entire data?
You have selected “A1:C5”.

What should I write so that it reads all the cells which contains some data. ?

You can set A:Z for example to select all columns from A to Z.

What if its beyond Z ?
Ex: AA or AB ?

exactly. I meant with A to Z if the data are only in A to Z.
If you don’t give a number, the hole column will be copied.
A:B means: Columns A and B
A:Z means: Columns A to Z
D:AA means: Columns D to AA
etc.

What if i dont know how many columns would be there?

How to keep it dynamic?

Like we keep “” in read range activity

You can read the count of rows and count of columns and set them to your range.
See the new code:

Dim xlApp As Microsoft.Office.Interop.Excel.Application = New Microsoft.Office.Interop.Excel.Application

Try
	Dim xlWorkbook As Microsoft.Office.Interop.Excel.Workbook = xlApp.Workbooks.Open(Path)
	
	'Define Excel Sheet
	Dim xlWorksheet As Microsoft.Office.Interop.Excel.Worksheet
	
	xlWorksheet = CType(xlWorkbook.Sheets("Sheet1"), Microsoft.Office.Interop.Excel.Worksheet)
	
	'Activate Worksheet
	xlWorksheet.Activate()
	
	'Get Rows Count
	Dim RowsCount As Integer
	RowsCount = xlWorksheet.UsedRange.Rows.Count
	
	'Get Columns Count
	Dim ColumnsCount As Integer
	ColumnsCount = xlWorksheet.UsedRange.Columns.Count
	
	'Format the numbers in Excel for all cells in column A
	'xlWorksheet.Range("A1:C5").Copy
	xlWorksheet.Range(xlWorksheet.Cells(1,1),xlWorksheet.Cells(RowsCount,ColumnsCount)).Copy
	
	'Close Workbook
	xlWorkbook.Close
	
Catch ex As Exception
	Throw ex
Finally
	'Close Excel Application
	xlApp.Quit
End Try

Thanks a lot brother!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.