JuanFelipe Posted October 3, 2018 Posted October 3, 2018 Hello friends, I have a query, it happens that I have a matrix nxn, the first column of this contains each cell a number with 21 digits, when I pass this matrix to Excel I obviously write that number as 1,10016E + 20, I solved it by adding a * at the end of each cell, but I want it to be written as a text so that I do not have to remove that *, I searched in Google but could not find an effective solution, thanks in advance.
FrancescoDiMuro Posted October 3, 2018 Posted October 3, 2018 @JuanFelipe Maybe this? Always post your code Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
JuanFelipe Posted October 3, 2018 Author Posted October 3, 2018 (edited) 6 minutes ago, FrancescoDiMuro said: @JuanFelipe Maybe this? Always post your code This is the function I am using to write the matrix in Excel, but what I need is to know how to write that information in the text format, just like the Excel cells. _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $TablaTotal, "A1", True) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "", "Error writing to worksheet." & @CRLF & "@error = " & @error & ", @extended = " & @extended) MsgBox($MB_SYSTEMMODAL, "", "Terminado",1) Edited October 3, 2018 by JuanFelipe
JuanFelipe Posted October 3, 2018 Author Posted October 3, 2018 expandcollapse popup;=============================================================================== ; ; Description: Applies the specified formatting to the cells in the specified R1C1 Range. ; Syntax: _ExcelNumberFormat($oExcel, $sFormat, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1) ; Parameter(s): $oExcel - An Excel object opened by a preceding call to _ExcelBookOpen() or _ExcelBookNew() ; $sFormat - The formatting string to apply to the specified range (see Notes below) ; $sRangeOrRowStart - Either an A1 range, or an integer row number to start from if using R1C1 ; $iColStart - The starting column for the number format(left) ; $iRowEnd - The ending row for the number format (bottom) ; $iColEnd - The ending column for the number format (right) ; Requirement(s): None ; Return Value(s): On Success - Returns 1 ; On Failure - Returns 0 and sets @error on errors: ; @error=1 - Specified object does not exist ; @error=2 - Starting row or column invalid ; @extended=0 - Starting row invalid ; @extended=1 - Starting column invalid ; @error=3 - Ending row or column invalid ; @extended=0 - Ending row invalid ; @extended=1 - Ending column invalid ; Author(s): SEO <locodarwin at yahoo dot com> ; Note(s): For more information about possible formatting strings that can be ; used with this command, consult the book, "Programming Excel With ; VBA and .NET," by Steven Saunders and Jeff Webb, ISBN: 978-0-59-600766-9 ; ;=============================================================================== Func _ExcelNumberFormat($oExcel, $sFormat, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1) If NOT IsObj($oExcel) Then Return SetError(1, 0, 0) If NOT StringRegExp($sRangeOrRowStart, "[A-Z,a-z]", 0) Then If $sRangeOrRowStart < 1 Then Return SetError(2, 0, 0) If $iColStart < 1 Then Return SetError(2, 1, 0) If $iRowEnd < $sRangeOrRowStart Then Return SetError(3, 0, 0) If $iColEnd < $iColStart Then Return SetError(3, 1, 0) With $oExcel.ActiveSheet .Range(.Cells($sRangeOrRowStart, $iColStart), .Cells($iRowEnd, $iColEnd)).NumberFormat = $sFormat EndWith Return 1 Else $oExcel.ActiveSheet.Range($sRangeOrRowStart).NumberFormat = $sFormat Return 1 EndIf EndFunc ;==>_ExcelNumberFormat Thanks, I solved it with the ExcelCOM_UDF.au3. _ExcelNumberFormat($oWorkbook, "@", "A:A")
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now